IOS8 PUSH

registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later

// 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);
}

时间: 2024-08-14 00:32:18

IOS8 PUSH的相关文章

iOS8 Push Notifications

本文转载至 http://blog.csdn.net/pjk1129/article/details/39551887 原贴地址:https://parse.com/tutorials/ios-push-notifications github地址:https://github.com/ParsePlatform/PushTutorial iOS Push通知已经广泛应用于实际开发中,iOS8与之前注册push有所不同,这里把如何潜入代码贴一下,以作记录,详情请看上面地址链接 Adding Co

iOS8 PUSH解决方法

本文转载至 http://blog.csdn.net/pjk1129/article/details/39548523 - (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types NS_DEPRECATED_IOS(3_0, 8_0, "Please use registerForRemoteNotifications and registerUserNotificationSettings: instea

开发者福利:iOS开发学习资源、解决方案大放送

百度iOS入门教程http://wenku.baidu.com/course/view/1ce3571252d380eb62946d8c M了个J博客 http://www.cnblogs.com/mjios/tag/objective-c/ iOS应用源码保护:http://www.ijiami.cn/ios Cocoa China http://www.cocoachina.com git网 https://git.oschina.net 开源中国社区 http://www.oschina.

ios常用资源网址链接

M了个J博客 http://www.cnblogs.com/mjios/tag/objective-c/  Cocoa China http://www.cocoachina.com  git网 https://git.oschina.net  开源中国社区 http://www.oschina.net  iOS命令行 http://blog.sina.com.cn/s/blog_71715bf801016di7.html  摄像头https://developer.apple.com/libr

ios8以后,使用UIAlertViw时pop/push页面后,键盘闪一下的问题

代码为 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"感谢你对我们提出的意见或建议,你的支持就是我们进步的动力!" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil]; [alert show]; -(void)alertView:(UIAlertView *)alertV

iOS8下注册push方式变更

if (IOS8_) { UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert) categories:nil]; [application registerUserNotificationSetti

IOS8下的远程推送(转载)

原文地址:http://blog.sina.com.cn/s/blog_71715bf80101615c.html 昨天做了一下远程推送,今天写下来,分享给需要的人.参考了很多篇文章,或许是iOS8的改动,没有一篇可以完整的看下来,所以打算自己写一篇. 后台我也写了,用的是SAE,PHP代码,很简单,调用SAE封装好的一个类就可以向APNS发推送信息. 首先,来说一下苹果的推送机制.顾名思义,推送,是指服务器向客户端发送消息,那么在iOS中,应用是被后台挂起的,并不能一直连接网络,那么服务器怎么

iOS8之后对定位和消息推送API的修改

1.定位 定位是定位,地图是地图,在iOS中 CLLocation是专门负责定位或者获取位置信息的;而MAPkit是专门负责地图显示的 位置管理器(CLLocationManager) :负责获取,同时负责监控用户位置发生变化        //[注意] 位置管理器一定要写成属性,不是属性出栈就没有了    _manager = [[CLLocationManager alloc] init];        //设置位置管理器代理   <CLLocationManagerDelegate> 

iOS - 判断用户是否允许推送通知(iOS7/iOS8)

(iOS8中用户开启的推送通知类型对应的是UIUserNotificationType(下边代码中UIUserNotificationSettings的types属性的类型),iOS7对应的是UIRemoteNotificationType) 此处以iOS8的UIUserNotificationType为例,(如下图)当本地通知或push/远程通知 推送时,这个常量指明了app如何去提醒用户(比如:Badge,Sound,Alert的组合) 那么如何获得呢,在iOS8中是通过types属性,[[