我有一個應用程序,我使用APNS發送推送通知。我曾嘗試使用下面的代碼推送通知不適用於iOS 7,但適用於iOS8
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0 //__IPHONE_8_0 is not defined in old xcode (==0). Then use 80000
NSLog(@"registerForPushNotification: For iOS >= 8.0");
[[UIApplication sharedApplication] registerUserNotificationSettings:
[UIUserNotificationSettings settingsForTypes:
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)
categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
#endif
}
else {
NSLog(@"registerForPushNotification: For iOS < 8.0");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
}
我發現ID通知與iOS 8及更高版本的設備工作,但iOS7設備上它甚至做了詢問通知啓用,但它似乎在通知設置配置應用程序的通知。出了什麼問題?
您是否收到過兩個ios版本的設備令牌? – Surjeet
@Surjeet是我收到的令牌爲兩個和在iOS 8它的工作原理,嘗試在iPad 2以及iPhone 4 –
您可以檢查以下方法中的任何錯誤? - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err –