registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later
本文转载至 http://bbs.csdn.net/topics/390889517
IOS8 PUSH解决方法
昨天晚上整理PUSH的东西,准备些一个教程,全部弄好之后,发现没有达到预期的效果,本以为是服务器代码的问题(因为本人对PHP代码一点都不懂),所以在网上四处搜索,后来看xcode log才发现,原来是IOS8系统更新了的问题,提示 registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
使用IOS8 xcode6的同学,在使用推送(push)的时候应该已经出现这个问题了。那么让我们来看看具体的解决方法。
iOS 8 has changed notification registration in a non-backwards compatible way. While you need to support iOS 7 and 8 (and while apps built with the 8 SDK aren't accepted), you can check for the selectors you need and conditionally call them correctly for the running version.
Here's a category on UIApplication that will hide this logic behind a clean interface for you that will work in both Xcode 5 and Xcode 6.
// IOS8 新系统需要使用新的代码咯
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings
settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)
categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
//这里还是原来的代码
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
原本在IOS7当中 判断PUSH是否打开的方法是:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
return (types & UIRemoteNotificationTypeAlert);
如果将这段代码使用在 IOS当中,虽然不会出现crash的现象,但是基本没什么作用。
在IOS8中,我们使用如下的新代码来取代以上的代码
{
UIRemoteNotificationType types;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
}
else
{
types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
}
return (types & UIRemoteNotificationTypeAlert);
}
每当苹果更新一个新的版本的时候,最痛苦的莫过于我们这群屌丝啊
加油码农!
本文转自 http://www.999dh.net/home.php?mod=space&uid=1&do=blog&quickforward=1&id=419 转载请注明!!
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later的更多相关文章
- registerForRemoteNotificationTypes: is not supported in iOS 8.0 and
注册模式: if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [[UIApplication sharedA ...
- iOS iOS8中 问题"registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later" 解决方式
问题重述: iOS 8中改变了通知注冊的方式,假设App须要同一时候支持iOS 7 和 8 的话,须要首先检查selector. 解决方式:在Xcode 6中 - (BOOL)application: ...
- embedded dylibs/frameworks are only supported on iOS 8.0 and later 错误解决
ld: warning: embedded dylibs/frameworks only run on iOS 8 or later ld: embedded dylibs/frameworks ar ...
- iOS开发Embedded dylibs/frameworks are only supported on iOS 8.0 and later for architecture armv7的解决方法
全局搜索IPHONEOS_DEPLOYMENT_TARGE改为更小的版本
- iOS 10.0 更新点(开发者视角)
html, body {overflow-x: initial !important;}html { font-size: 14px; } body { margin: 0px; padding: 0 ...
- HierarchyViewer for iOS 2.0 BETA Introduction
We know HierarchyViewer is an useful tool in Android SDK. The developer and tester, who haven't the ...
- iOS 7.0获取iphone UDID 【转】
iOS 7.0 iOS 7中苹果再一次无情的封杀mac地址,使用之前的方法获取到的mac地址全部都变成了02:00:00:00:00:00.有问题总的解决啊,于是四处查资料,终于有了思路是否可以使用K ...
- iOS 5.0 后UIViewController新增:willMoveToParentViewController和didMoveToParentViewCon[转]
在iOS 5.0以前,我们在一个UIViewController中这样组织相关的UIView 在以前,一个UIViewController的View可能有很多小的子view.这些子view很多时候 ...
- iOS 5.0 后UIViewController新增:willMoveToParentViewController和didMoveToParentViewCon
在iOS 5.0以前,我们在一个UIViewController中这样组织相关的UIView 在以前,一个UIViewController的View可能有很多小的子view.这些子view很多时候 ...
随机推荐
- bzoj 3924 幻想乡战略游戏
题目大意: 有边权点权的树,动态修改点权 每次修改后求带权重心x (\(minimize\) \(S=\sum_i val[i]*dist[x][i]\)) 分析: 从暴力找突破口: 对于边x,y,设 ...
- 创建 Image
本节演示如何通过 Web GUI 和 CLI 两种方法创建 Image. OpenStack 为终端用户提供了 Web UI(Horizon)和命令行 CLI 两种交换界面.两种方式我们都要会用. 可 ...
- 开始学习es6(一) 搭建个es6的开发环境
1.开始学习es6 如果想在浏览器跑es6 需要给es6个环境 因为一直用vue-cli全家桶 这样虽然方便 但如果用es6需要跑起个vue全家桶 于是想到可以用gulp搭建个开发环境 首先需要1. ...
- vue2.0组件入门
如何定义一个组件 在根目录src/components/文件夹下新建组件的文件夹Footer.vue组件 在Footer.vue中 <template> <div class=&qu ...
- XML布局文件于Java代码使用问题
2013-9-21 问题一.不同的XML文件中相同类型的控件id相同,那么将这些不同的布局xml组合在一个大的布局中,如何解决相同id问题 ? 解决办法: 不同的布局文件XML要组合成一个新的大布局, ...
- 第0章Linux环境到内核基础知识
#include<stdio.h> int main(void) { printf("hello world\n"); return 0; } gcc -g -wall ...
- 为IIS增加PHP支持
环境: win2008x64 + PHP5.3
- hdu 5459(递推好题)
Jesus Is Here Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/102400 K (Java/Others)To ...
- java mail Received fatal alert: handshake_failure java 无法发送邮件问题 java 发送qq邮件(含源码)
java 无法发送邮件问题 java 发送qq邮件 报错:java mail Received fatal alert: handshake_failure (使用ssl) javax.mail.M ...
- tomcat7.0.55配置单向和双向HTTPS连接(二)
上一篇文章:tomcat7.0.55配置单向和双向HTTPS连接 只是简要的配置了一下HTTPS,还有许多问题没有解决,本篇来解决这些文件 首先按照这篇文章:Widows下利用OpenSSL生成证书来 ...