2016-11-11 18 views
0

我試圖簡單地爲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檢查。

有沒有人有任何問題,如果是這樣,你是如何解決的?

+0

你是否有機會在模擬器上測試它?在模擬器上,它默默地失敗了,但實際上它不被支持,至少應該拋出一個錯誤,但是我該告訴誰。 – nullpotent

+0

好問題,但沒有。我正在使用我的設備。 – jdmdevdotnet

+1

你在ios 10上嗎?有一些[更改](https://blog.xamarin.com/getting-started-with-the-ios-10-notification-framework/) – nullpotent

回答

0

哇。我覺得我好笨。

因此,事實證明,即使您的解決方案配置設置爲Release,也可以通過斷點調試Xamarin.Forms。但是如果您的解決方案配置設置爲Release,則無法通過斷點調試特定於平臺的代碼。將其設置爲Debug可以修復它。我只是從來沒有這樣做過,因爲你可以在Xamarin.Forms版本中調試斷點。