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您提供的代码应该在后台工作。 –