码迷,mamicode.com
首页 > 移动开发 > 详细

iOS7、iOS8推送通知的区别

时间:2016-01-06 15:57:01      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

iOS8版本以后的推送通知代码
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
//注意下面这句,在iOS8 中注册推送通知必须要加上[[UIApplication sharedApplication] registerForRemoteNotifications];
iOS8版本以前的推送通知代码
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
如果要同时兼容iOS7 与 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)];    
}
ios8 横屏状态栏不显示

解决方法:在plist文件中将 View controller-based status bar appearance 设置为NO  在application:didFinishLaunchingWithOptions:中添加下面代码[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; 
iOS8 横屏的时候系统默认隐藏了  。。这个是ios8新特性 

地图
 
友盟分享  分享到微信注意点

iOS7、iOS8推送通知的区别

标签:

原文地址:http://www.cnblogs.com/GhostKZShadow/p/5105508.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!