我試圖簡單地爲Xamarin iOS應用程序設置推送通知。我確定我正在使用具有必要權限的配置配置文件(在iOS開發人員門戶中啓用推送通知)。我已經驗證我在我的應用程序中使用了提供配置文件。在我的AppDelegate,在FinishedLaunching方法,我執行以下代碼:遠程通知方法沒有被擊中
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
}
else
{
UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
}
我可以成功地看到詢問用戶是否要允許推送通知的提示。這裏的問題是,當我在Allow
挖掘,既不以下重載方法被擊中:
RegisteredForRemoteNotifications
FailedToRegisterForRemoteNotifications
我還證實,在我的iOS項目設置,我已經Enable BackgroundModes
檢查以及如RemoteNotifications
檢查。
有沒有人有任何問題,如果是這樣,你是如何解決的?
你是否有機會在模擬器上測試它?在模擬器上,它默默地失敗了,但實際上它不被支持,至少應該拋出一個錯誤,但是我該告訴誰。 – nullpotent
好問題,但沒有。我正在使用我的設備。 – jdmdevdotnet
你在ios 10上嗎?有一些[更改](https://blog.xamarin.com/getting-started-with-the-ios-10-notification-framework/) – nullpotent