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

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

问题描述

我upgarded我的X code与X code 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.

我添加的应用程序委托的code以下提到:

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

即使当前通知是present,并且它不是nil

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上code路径,注册用户通知设置后。

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

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

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