我已经浏览了iOS本地通知的Xamarin演练:
我无法让它发挥作用。它构建正常,但ReceivedLocalNotification
上的AppDelegate
方法永远不会触发。我做错了什么?
答案 0 :(得分:3)
如果您使用的是iOS 8,您还需要注册您的应用以接收通知,如下所述:
将以下代码添加到FinishedLaunching
类的AppDelegate
方法中:
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) {
UIUserNotificationType notificationTypes = UIUserNotificationType.Alert |
UIUserNotificationType.Badge |
UIUserNotificationType.Sound;
var userNoticationSettings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, new NSSet(new string[] {}));
UIApplication.SharedApplication.RegisterUserNotificationSettings (userNoticationSettings);
}