推送通知 – 推送通知在iOS 9中不起作用

前端之家收集整理的这篇文章主要介绍了推送通知 – 推送通知在iOS 9中不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已将我的设备升级到iOS 9和我的 Xcode环境到7.0
公测.推送通知在iOS 9中不起作用?

这是我的代码

float ver = [[[UIDevice currentDevice] systemVersion] floatValue];

    if(ver >= 8 && ver<9)
    {
        if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
        {
            [[UIApplication sharedApplication] registerForRemoteNotifications];
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

        }
    }else if (ver >=9){

        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

        [[UIApplication sharedApplication] registerForRemoteNotifications];


    }
    else{
        //iOS6 and iOS7 specific code
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert];
    }

使用Xcode 6.4构建的iOS 8至8.3上的推送通知功能正常.

解决方法

在您的项目中添加代码并创建证书和Ad-Hoc配置文件后,

*只需从你的X代码*

更多细节 – iOS 9 Push Notification Tutoriyal

猜你在找的iOS相关文章