对于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