對於iOS7,解析處理推送通知,在AppDelegate中下面的代碼:如何根據iOS版本處理推送通知?
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge|
UIRemoteNotificationTypeAlert|
UIRemoteNotificationTypeSound];
registerForRemoteNotificationTypes
在iOS8上不支持然而,和用於處理現在iOS8上的推送通知新的代碼如下所示:
UIUserNotificationSettings *settings =
[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound
categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
在iOS7設備上使用此新代碼會導致應用程序崩潰,因此我需要讓代碼確定手機的版本,然後運行相應的推送通知代碼。我如何讓應用程序檢查這個,並使用正確的?
[registerForRemoteNotificationTypes:在iOS 8.0及更高版本中不受支持]的可能重複(http://stackoverflow.com/questions/24454033/registerforremotenotificationtypes-is-not-supported-in-ios-8-0-and-later ) – 2014-09-21 06:09:32