ios8推送问题

博文转载至  http://blog.csdn.net/cerastes/article/details/39546625

ios8push推送通知适配

ios8推送问题

registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

 

[objc] view plaincopy
 
  1. if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)  
  2. {  
  3.     [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings   
  4.      settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)        
  5. categories:nil]];  
  6.   
  7.   
  8.     [[UIApplication sharedApplication] registerForRemoteNotifications];  
  9. }  
  10. else  
  11. {  
  12. //这里还是原来的代码  
  13.     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:  
  14.      (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];  
  15. }  

 

判断PUSH是否打开

 

[objc] view plaincopy
 
  1. {  
  2. UIRemoteNotificationType types;  
  3. if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)  
  4.    {  
  5.  types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;  
  6.     }  
  7. else  
  8.    {  
  9.  types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];  
  10.     }  
  11.   
  12.   
  13. return (types & UIRemoteNotificationTypeAlert);  
  14. }  
posted @ 2015-04-28 16:42  天牛  阅读(152)  评论(0编辑  收藏  举报