Parse没有工作ios 7

时间:2014-12-08 19:16:09

标签: ios xcode parse-platform

当我在iOS7设备上运行时,我的应用程序崩溃了!

所以我试过了:

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

iOS 8设备正确,但iOS 7设备推送通知无效:(

任何想法?

注意:

我有我使用的另一个应用程序的代码:

[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
 UIRemoteNotificationTypeAlert|
 UIRemoteNotificationTypeSound];

但现在无法正常工作

1 个答案:

答案 0 :(得分:0)

我已将此代码用于iOS 7的当前应用,并且工作正常。 在ApplicationDidFinishLaunchingWithOptions写下你之前写过的内容。

[application registerForRemoteNotificationTypes:
     UIRemoteNotificationTypeBadge |
     UIRemoteNotificationTypeAlert |
     UIRemoteNotificationTypeSound];

不要忘记将此添加到您的AppDelegate

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
    [application registerForRemoteNotifications];
}

在没有日志消息的情况下很难知道代码中缺少了什么,但我的猜测是你没有注册用户进行通知设置。干杯!