標籤:
博文轉載至 http://blog.csdn.net/cerastes/article/details/39546625ios8push推播通知適配
ios8推送問題
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
[objc] view plaincopy
- 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)];
- }
判斷PUSH是否開啟
[objc] view plaincopy
- {
- UIRemoteNotificationType types;
- if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
- {
- types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
- }
- else
- {
- types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
- }
-
-
- return (types & UIRemoteNotificationTypeAlert);
- }
ios8推送問題