objective-c - 为什么应用程序没有在 iOS 8 中注册推送通知?

标签 objective-c iphone apple-push-notifications ios8 xcode6

我将我的 Xcode 升级到 Xcode 6.0.1,现在 iOS 8 设备不会发生远程通知注册。它适用于 iOS 7 设备。

我已经在 app delegate 中添加了如下所述的代码:

    //-- Set Notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
     |UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert) categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

    NSLog(@"current notifications : %@", [[UIApplication sharedApplication] currentUserNotificationSettings]);
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

即使当前通知存在,也不是零。

但是下面的方法没有被调用:

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

下面的屏幕截图解释了我在后台模式下启用了某些选项:

enter image description here

通知是在我的应用的设备设置中设置的。

最佳答案

你需要打电话

[[UIApplication sharedApplication] registerForRemoteNotifications];

在您的 iOS8 代码路径中,在注册用户通知设置之后。

关于objective-c - 为什么应用程序没有在 iOS 8 中注册推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26053220/

相关文章:

ios - IOS UIScrollView 中位置坐标值加倍

iphone - MBProgressHUD armv7 错误

ios - iOS下载自定义推送通知声音

c# - 无法发送带有分发证书的 APNS 消息

objective-c - 使用带有 Objective-C 语言定义的 Sonar

ios - 我应该将dispatch_group_leave包装在@synchronized block 中吗?

ios - 进入全屏时 iPhone 上的 MPMoviePlayerController 暂停

iphone - 底部弹出UIPicker?

iphone - 在禁用按钮的情况下淡入淡出图像

php - stream_socket_client 在我的服务器上失败,无法了解有关错误的更多信息