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. }  

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。