xamarin registerForRemoteNotificationTypes:iOS 8.0及更高版本不支持

时间:2014-09-23 07:46:51

标签: push-notification xamarin ios8

我使用Xamarin开发我的iOS应用程序,但随着iOS 8的发布,我在注册推送通知方面遇到了问题。我在iOS 7 SDK下编写的代码出现以下错误:

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

我知道我不需要使用已经折旧的" RegisterForRemoteNotificationTypes()",而是使用" registerUserNotificationSettings & #34; &安培; "的 registerForRemoteNotifications "

以下链接可以帮助它在C#中使用Xamarin库: registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later

我在" UIApplication.SharedApplication下找了那些方法。"但是找不到它们......我在寻找错误的地方吗? (我在构建设置中定位了iOS 8。)

非常感谢任何帮助

1 个答案:

答案 0 :(得分:3)

这应该可以解决问题:

var settings = UIUserNotificationSettings.GetSettingsForTypes(
    UIUserNotificationType.Alert 
    | UIUserNotificationType.Badge 
    | UIUserNotificationType.Sound, 
    new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
UIApplication.SharedApplication.RegisterForRemoteNotifications ();
相关问题