iPhone6(iOS 8)中的推送通知不工作
以下是我在appDelegate中编写的与Apple推送通知相关的代码。对我来说,这是一个奇怪的问题,我没有在IPHONE6 IOS8中收到推送通知,而是在其他设备和其他版本中收到推送。如果我缺少什么,我是否需要为IPHONE6 IOS8做些其他的事情。请建议帮助我解决这个问题iPhone6(iOS 8)中的推送通知不工作,ios,objective-c,apple-push-notifications,ios8.1,iphone-6,Ios,Objective C,Apple Push Notifications,Ios8.1,Iphone 6,以下是我在appDelegate中编写的与Apple推送通知相关的代码。对我来说,这是一个奇怪的问题,我没有在IPHONE6 IOS8中收到推送通知,而是在其他设备和其他版本中收到推送。如果我缺少什么,我是否需要为IPHONE6 IOS8做些其他的事情。请建议帮助我解决这个问题 - (void)callPushNotificationDelegate { if ([[UIApplication sharedApplication] respondsToSelector:@selector(r
- (void)callPushNotificationDelegate {
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
#ifdef __IPHONE_8_0
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
#endif
} else {
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
}
pragma标记-远程通知委托
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
}
#endif
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
NSLog(@"Failed to get token, error: %@", error);
}