不久之后iPhone 6/6 plus就会在国内如雨后春笋般遍地开花了。iOS 8早已现行一步,不过有的开发者也注意到了在iOS 8上推送通知的注册方式有所变化,报错提示为:

1
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

之后国外有开发者在使用了新的解决方案注册成功后发现在iPhone 6上仍然不能运行。鉴于iPhone 6/6 Plus将在国内开售,我们大可未雨绸缪一下。

iOS 8因为改变了推送消息的注册方式,所以在有推送需求的应用开发时,需要有些与以前不同的修改。然后可以试试在appDelegate.m文件的didFinishLaunchingWithOptions方法中加入下面一段代码以避免在iPhone 6/6 Plus上出现问题:

1
2
3
4
5
6
7
8
9
10
11
12
#ifdef __IPHONE_8_0 //这里主要是针对iOS 8.0,相应的8.1,8.2等版本各程序员可自行发挥,如果苹果以后推出更高版本还不会使用这个注册方式就不得而知了……
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}  else {
    UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
#else
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
#endif

然后在appDelegate.m中加入此方法:

1
2
3
4
5
6
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    [application registerForRemoteNotifications];
}
#endif

iOS8 推送注册方式改变的问题的更多相关文章

  1. ios8推送问题

    博文转载至  http://blog.csdn.net/cerastes/article/details/39546625 ios8push推送通知适配 ios8推送问题 registerForRem ...

  2. iOS7、iOS8推送通知的区别

    iOS8版本以后的推送通知代码[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificati ...

  3. iOS8推送消息的快速回复处理

    http://blog.csdn.net/yujianxiang666/article/details/35260135 iOS8拥有了全新的通知中心,有全新的通知机制.当屏幕顶部收到推送时只需要往下 ...

  4. iOS 远程推送注册的小问题

    iOS8有了新方法,用新方法后,用7.0版本运行会奔溃.只要加一句判断就ok: #ifdef __IPHONE_8_0 // 在 iOS 8 下注册苹果推送,申请推送权限. UIUserNotific ...

  5. FCM实现手机推送,推送的方式,真机调试

    FCM实现手机 1 下载Androidstudio 3.2 版本,之后新建一个项目 2  创建完项目之后查找文件AndroidMainifest.xml 3  访问网站注册一个自己的firebase的 ...

  6. 【转】iOS8 推送 获取 devicetoken

    标签:推送 push ios8 devicetoken token xcode6 原文:http://roybaby.blog.51cto.com/1508945/1557854 打开AppDeleg ...

  7. iOS8推送消息的回复处理速度

    iOS8我们有一个新的通知中心,我们有一个新的通报机制.当在屏幕的顶部仅需要接收一个推拉向下,你可以看到高速接口,天赋并不需要输入应用程序的操作.锁定屏幕,用于高速处理可以推动项目. 推送信息,再次提 ...

  8. 极光推送-Java后台实现方式一:Http API

    Java后台实现极光推送有两种方式,一种是使用极光推送官方提供的推送请求API:https://api.jpush.cn/v3/push,另一种则是使用官方提供的第三方Java APIjar包,这里先 ...

  9. 极光推送经验之谈-Java后台服务器实现极光推送的两种实现方式

    原创作品,可以转载,但是请标注出处地址http://www.cnblogs.com/V1haoge/p/6439313.html Java后台实现极光推送有两种方式,一种是使用极光推送官方提供的推送请 ...

随机推荐

  1. FLTK 1.3.3 VS 2010 Configuration 配置

    Download FLTK 1.3.3 Download VS2010 I assume you've already installed VS2010 correctly. Compile the ...

  2. hdu Oil Deposits

    因为这道题中给的数据比较小,所以可以直接用枚举的方式进行dfs搜索,每出现一个‘@’,就进行一次dfs的搜索,将所有相邻的‘@’全部变成‘*’. #include"iostream" ...

  3. SQLHelper 简介

    什么是SQLHelper SqlHelper是一个基于.NETFramework的数据库操作组件.组件中包含数据库操作方法,目前SqlHelper有很多版本,主要以微软一开始发布的SqlHelper类 ...

  4. JavaScript系列:replace()函数(第二个参数为函数)

    语法 stringobject.replace(regexp/substr,replacement) 只讲解这个:参数replacement为函数时,这个参数函数的参数代表的意义,以及运行次数,及过程 ...

  5. Django 1.8安装使用

    1.使用pip安装django, pip是什么,如何安装?自行放狗搜 # pip install "django<1.9" 2.创建项目 # django-admin sta ...

  6. 数据库中MyISAM与InnoDB区别

    数据库中MyISAM与InnoDB区别 首页 » DIY技术区 » 数据库中MyISAM与InnoDB区别 09:57:40   MyISAM:这个是默认类型,它是基于传统的ISAM类型,ISAM是I ...

  7. 判断i在字符串中出现的次数(2016.1.12P141-1)

    // 方法一,利用substring截取获得出现的次数 String number = "iminigrikejijavabi"; String a = number; int c ...

  8. 为什么数值类型byte取值范围是(-128~127)?

    在解决这个问题之前,我们先了解几个概念? 一.原码, 反码, 补码的概念 正数的反码和补码都与原码一样: 负数的反码.补码与原码不同,负数的反码:原码中除去符号位,其他的数值位取反,0变1,1变0.负 ...

  9. LENGTH() CHAR_LENGTH()

    http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_length LENGTH(str) Returns the ...

  10. regardless of how many processors are devoted to a parallelized execution of this program

    https://en.wikipedia.org/wiki/Amdah's_law Amdahl's law is often used in parallel computing to predic ...