为什么应用程序没有在 iOS 8 中注册推送通知? [英] Why is app not getting registered for push notifications in iOS 8?

查看:30
本文介绍了为什么应用程序没有在 iOS 8 中注册推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I upgarded my Xcode to Xcode 6.0.1, now remote notification registration is not happening for iOS 8 device. It is working fine for iOS 7 device.

我在应用委托中添加了如下代码:

I have added the code in app delegate as mentioned below:

    //-- 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)];
}

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

Even the current notification is present, and it is not nil.

然而下面的方法没有被调用:

And yet the below method is not called :

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

下面的截图说明我在后台模式下启用了某些选项:

Screenshot below explains that I have enabled certain options in background mode:

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

And the notification is set in the device settings for my app.

推荐答案

需要拨打

[[UIApplication sharedApplication] registerForRemoteNotifications];

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

in your iOS8 code path, after registering the user notification settings.

这篇关于为什么应用程序没有在 iOS 8 中注册推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆