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,这样就不会出现忽略的文件了. ...
随机推荐
- C语言实现DES算法
原文转自 http://www.cnblogs.com/imapla/archive/2012/09/07/2674788.html 用C语言实现DES(数据加密算法)的一个例子,密文和密钥都是8个字 ...
- 标准C程序设计七---72
Linux应用 编程深入 语言编程 标准C程序设计七---经典C11程序设计 以下内容为阅读: <标准C程序设计>(第7版) 作者 ...
- python print 在命令行打印带颜色
红色 :print "\033[1;31m%s\033[0m" %("ALY : %s" %(['a','b']))
- /sys/class/gpio 文件接口操作IO端口(s3c2440)
http://blog.csdn.net/mirkerson/article/details/8464231 在嵌入式设备中对GPIO的操作是最基本的操作.一般的做法是写一个单独驱动程序,网上大多数的 ...
- Button Style Status
<Window x:Class="Dxsl.WPF.APP.Views.StyleTest2" xmlns="http://schemas.microsoft.co ...
- LeetCode OJ——Unique Binary Search Trees
class Solution { public: int numTrees(int n) { ); vector<int> numVector; numVector.assign(n+,) ...
- spring+jpa+HiKariCP+P6spy SSH HiKariCP P6spy
=============p6spy准备https://www.cnblogs.com/qgc88===================== 1.简单介绍p6spy,p6spy是一个开源项目,通常使用 ...
- AC日记——Pupils Redistribution Codeforces 779a
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input stan ...
- AC日记——Housewife Wind poj 2763
Language: Default Housewife Wind Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 10525 ...
- js判断鼠标滑轮滚动方向并根据滚动的方向触发不同的事件
<script> var scrollFunc = function (e) { var direct = 0; e = e || window.event; if (e.wheelDel ...