简体   繁体   English

解析不起作用的iOS 7

[英]Parse doesn't work ios 7

My app crash when i run on iOS7 device ! 当我在iOS7设备上运行时,我的应用程序崩溃了!

So i tried : 所以我试着:

#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 Device is correct but iOS 7 Device the push notification no working :( iOS 8设备正确,但iOS 7设备推送通知无效:(

any ideas? 有任何想法吗?

Note: 注意:

I have the code of another app i used: 我有我使用过的另一个应用程序的代码:

[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
 UIRemoteNotificationTypeAlert|
 UIRemoteNotificationTypeSound];

but now is not working 但现在不工作

I'm using this code for a current app of iOS 7 and it is working fine. 我将此代码用于iOS 7的当前应用程序,并且工作正常。 In ApplicationDidFinishLaunchingWithOptions write the same as you have written before. ApplicationDidFinishLaunchingWithOptions写入与之前相同的内容。

[application registerForRemoteNotificationTypes:
     UIRemoteNotificationTypeBadge |
     UIRemoteNotificationTypeAlert |
     UIRemoteNotificationTypeSound];

Don't forget to add this to your AppDelegate 不要忘记将其添加到您的AppDelegate

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

It is hard to know what you're missing in the code without the log message however my guess is that you didn't register user for notification settings. 没有日志消息很难知道您在代码中缺少什么,但是我的猜测是您没有为通知设置注册用户。 Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM