2014-09-23 60 views
2

我使用Xamarin開發我的iOS應用程序,但隨着iOS 8的發佈,我在註冊推送通知時遇到了問題。在iOS 7 SDK下編寫的代碼中出現以下錯誤:xamarin registerForRemoteNotificationTypes:在iOS 8.0和更高版本中不受支持

registerForRemoteNotificationTypes:在iOS 8.0及更高版本中不受支持。

我知道,而不是使用 「RegisterForRemoteNotificationTypes()」,它現在已經貶值,我需要使用 「registerUserNotificationSettings」 & 「registerForRemoteNotifications」。

下面的鏈接將幫助它,它使用Xamarin庫是在C#中:「UIApplication.SharedApplication」 registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later

我已經看了下那些方法但找不到他們...我在錯誤的位置看? (我的構建設置中已經定位了iOS 8)。

任何幫助,將不勝感激

回答

3

這應該做的伎倆:

var settings = UIUserNotificationSettings.GetSettingsForTypes(
    UIUserNotificationType.Alert 
    | UIUserNotificationType.Badge 
    | UIUserNotificationType.Sound, 
    new NSSet()); 
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); 
UIApplication.SharedApplication.RegisterForRemoteNotifications(); 
+0

原來,RegisteredForRemoteNotifications只會一次我的觀察調用。將設備令牌保存在設備和服務器上將是明智之舉。 – SgtRock 2014-10-02 15:10:04

相關問題