解析 - 推送通知在iOS 8中不起作用

时间:2014-09-22 17:18:05

标签: objective-c push-notification parse-platform ios8

我正在使用以下代码注册Parse:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                    UIUserNotificationTypeBadge |
                                                    UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                       categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
} else
#endif
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                                           UIRemoteNotificationTypeAlert |
                                                                           UIRemoteNotificationTypeSound)];
}

在iOS 7中它运行正常,但是当我从iOS 8发送推送时,它无法正常工作并返回此错误:

  

enabledRemoteNotificationTypes is not supported in iOS 8.0 and later parse.

知道我做错了吗?

1 个答案:

答案 0 :(得分:0)

根据错误和documentation,iOS 8不推荐使用enabledRemoteNotificationTypes

  

请改用isRegisteredForRemoteNotifications方法。