iOS8 PUSH解决方法
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types NS_DEPRECATED_IOS(3_0, 8_0, "Please use registerForRemoteNotifications and registerUserNotificationSettings: instead")
使用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 转载请注明!!
iOS8 PUSH解决方法的更多相关文章
- UITableViewCell点击不能push解决方法
一般情况下不能push是因为当前控制器没有导航控制器,造成不能push的情况. 解决方法如下: - (void)tableView:(UITableView *)tableView didSelect ...
- git rebase与 git合并(error: failed to push some refs to)解决方法
1.遇到的问题 本地有一个git仓库,在github上新建了一个空的仓库,但是更新了REWADME.md的信息,即在github上多了一个提交. 关联远程仓库,操作顺序如下: git remote a ...
- jenkins在windows服务器上执行含git push命令的脚本权限不足的解决方法
错误摘要 默认情况下执行脚本是没问题的,但是脚本中含有git push命令就无法执行了 用jenkins部署hexo博客时候遇到的,执行hexo d -g一直阻塞至Build was aborted, ...
- 〖Linux〗git push orgin master不能解析域名的解决方法
错误信息: $ git push origin master ssh: Could not resolve hostname bitbucket.org: Name or service not kn ...
- push到github报错解决方法
在push代码到远程仓库时,报了如下的错误: $ git push -u origin master To https://github.com/11pdg/group-buy.git ! [reje ...
- 页面跳转问题,多次 push 到新的页面的问题的解决方法
今日在做一个扫一扫的功能,突然发现多次点击了扫一扫的图片后,造成多次触发轻拍手势,就多次push到新的页面,本想在轻拍手势内对push的进行拦截,但是又觉得如果有好多的地方都要实现对该问题的解决岂不是 ...
- [git push] rejecteded 问题的解决方法
错误信息: hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart ...
- Missing Push Notification Entitlement解决方法
原委 最近提交APP到Apple Store审核,结果很快就收到Apple很"贴心"的邮件.原文如下: Dear developer, We have discovered one ...
- git push的时候.gitignore不起作用的解决方法
问题的原因 这是因为在你添加.gitignore之前已经进行过push操作,有些文件已经纳入版本管理了. 解决方法 我们就应该先把本地缓存删除,然后再进行git的push,这样就不会出现忽略的文件了. ...
随机推荐
- .net EF框架
https://blog.csdn.net/u012235352/article/details/82768897 model first https://blog.csdn.net/u0101783 ...
- 视频流传输协议RTP/RTCP/RTSP/HTTP的区别 (转)
用一句简单的话总结:RTSP发起/终结流媒体.RTP传输流媒体数据 .RTCP对RTP进行控制,同步.之所以以前对这几个有点分不清,是因为CTC标准里没有对RTCP进行要求,因此在标准RTSP的代码中 ...
- linux 头文件以及库的路径
原来在编译的时候可以指定执行时去哪里找需要的lib文件,长知识了 本文详细介绍了Linux 下gcc头文件指定方法,以及搜索路径顺序的问题.另外,还总结了,gcc动态链接的方法以及路径指定,同样也讨论 ...
- 在tomcat发布项目遇到的问题
今天从SVN上把系统导入本地发生了异常,问题如下: java.math.BigInteger cannot be cast to java.lang.Long 百度一番后发现是因为使用Mysql8.0 ...
- 常用工具篇(二)死链接扫描工具–Xenu
一个网站上线一段时间之后,可能出现很多的死链接,死链接就是那些打不开的链接,或者是请求是404的,可能是因为有的文件位置移动了,或者有的功能不好使了,可能会影响我们网的功能,我们就要隔一阵扫描一下网站 ...
- jQuery实现tab选项卡效果小demo
html页面: <section> <h2>Section Title</h2> <ul class="tab-nav"> < ...
- AngularJS中使用Directive、Controller、Service
AngularJS是一款非常强大的前端MVC框架.同时,它也引入了相当多的概念,这些概念我们可能不是太熟悉. (1)Directive 指令 (2)Controller 控制器 (3)Service ...
- PyTorch学习笔记之n-gram模型实现
import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as ...
- 数据结构------------------二叉查找树(BST)的java实现
数据结构------------------二叉查找树(BST)的java实现 二叉查找树(BST)是一种能够将链表插入的灵活性和有序数组查找的高效性相结合的一种数据结构.它的定义如下: 二叉查找树是 ...
- 【Jpa hibernate】一对多@OneToMany,多对一@ManyToOne的使用
项目中使用实体之间存在一对多@OneToMany,多对一@ManyToOne的映射关系,怎么设置呢? GitHub地址:https://github.com/AngelSXD/myagenorderd ...