Tag Archives: registerForRemoteNotification

registerForRemoteNotification in iOS 8,新系统iOS 8下推送注册

有没有发现你的应用在新系统iOS 8下,推送服务不工作了?

嘿嘿,新的iOS 8环境中,远程推送注册已经采用了新的方法,之前(如下)的办法要失效了:

[[UIApplicationsharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];

如果你有意开始升级你的应用,现在应该为iOS 8环境考虑了,要采用下面新的办法:

        NSSet *categories = nil;

        [[UIApplicationsharedApplication] registerForRemoteNotifications];

        [[UIApplicationsharedApplication] registerUserNotificationSettings:[UIUserNotificationSettingssettingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSoundcategories:categories]];

如果你还不知道怎么构造 categories,那暂时使用 nil 值吧。