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. }  
原文地址:https://www.cnblogs.com/Camier-myNiuer/p/4463426.html