[英]iOS Push Notifications Working on iOS 8 But Not on iOS 7 in iOS SDK 8.1
if([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
[self registerForiOS8PushSettings]; //for iOS8
} else {
//iOS7 or earlier
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
無法獲得推送通知到iOS7設備。 didRegisterForRemoteNotificatiosnWithDeviceToken
被調用,實際上消息已成功傳遞。 在iOS8上運作良好。
有了iOS8,過程發生了變化。 要使您的應用注冊iOS8和早期版本,請執行以下操作:
-(void)registerAppForNotifications{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeNewsstandContentAvailability| UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.