簡體   English   中英

Xamarin iOS本地通知不起作用

[英]Xamarin iOS Local Notifications not working

我已經在iOS本地通知中完成了Xamarin演練:

http://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/ios/local_notifications_in_ios_walkthrough/

我就是無法正常工作。 它構建良好,但是AppDelegate上的ReceivedLocalNotification方法從不觸發。 我究竟做錯了什么?

如果您使用的是iOS 8,則還需要注冊您的應用以接收通知,如下所述:

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW1

將以下代碼添加到AppDelegate類的FinishedLaunching方法中:

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);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM