推送通知在 iOS 9 中不起作用 [英] Push notifications are not working in iOS 9

查看:44
本文介绍了推送通知在 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) 类别:nil];[[UIApplication sharedApplication] registerUserNotificationSettings:settings];}}else if (ver >=9){[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) Categories:nil]];[[UIApplication sharedApplication] registerForRemoteNotifications];}别的{//iOS6和iOS7具体代码[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert];}

推送通知在使用 Xcode 6.4 构建的 iOS 8 到 8.3 上运行良好.

解决方案

在您的项目中添加code并创建证书和Ad-Hoc Profile之后-

*只需从您的 X-code 启用此功能*

了解更多详情 - iOS 9 推送通知教程

I have upgraded my devices to iOS 9 and my Xcode environment to 7.0 beta. Push notifications are not working in iOS 9?

Here is my code:

  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];
    }

Push notifications are working fine on iOS 8 to 8.3 built with Xcode 6.4.

解决方案

After adding the code in your project and creating the certificate and Ad-Hoc Profile -

*Just enable this from your X-code*

for more details - iOS 9 Push Notification Tutoriyal

这篇关于推送通知在 iOS 9 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆