0
我正在使用Xam.Plugins.Notifier包在Xamarin.Forms項目中實現本地通知。Xam.Plugins.Notifier不適用於IOS 11
這是我在PCL項目中編寫的代碼。 CrossLocalNotifications.Current.Show(「Title」,「Description」);
它適用於Android,但它不適用於IOS。 我不確定它是否適用於較低的IOS sdk。 反正它不會在IOS 11
在這裏工作是我在AppDelegate.cs添加
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// Ask the user for permission to get notifications on iOS 10.0+
UNUserNotificationCenter.Current.RequestAuthorization(
UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
(approved, error) => { });
}
else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
// Ask the user for permission to get notifications on iOS 8.0+
var settings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
}
任何人可以幫助我解決它的代碼? 我想讓這個包在IOS上工作。
謝謝。
感謝您的回覆,我已經自己處理了。如果它在後臺不起作用,應該添加什麼。 –
@ Passionate.C您提供的代碼應該在後臺工作。 –