Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone6(iOS 8)中的推送通知不工作_Ios_Objective C_Apple Push Notifications_Ios8.1_Iphone 6 - Fatal编程技术网

iPhone6(iOS 8)中的推送通知不工作

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

以下是我在appDelegate中编写的与Apple推送通知相关的代码。对我来说,这是一个奇怪的问题,我没有在IPHONE6 IOS8中收到推送通知,而是在其他设备和其他版本中收到推送。如果我缺少什么,我是否需要为IPHONE6 IOS8做些其他的事情。请建议帮助我解决这个问题

- (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);
}