繁体   English   中英

推送通知已停止适用于IOS 8

[英]Push notification stopped working for IOS 8

我使用支持推送通知功能的企业证书对应用程序进行了签名。 一切正常,当我将iPhone更新为iOS 8时,推送通知停止工作。 经过调试和很少的研究之后,我知道要添加以下代码来从iOS 8开始检索推送令牌。

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) //>iOS8
{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}else {// <iOS8
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

}

Add following callback methods,

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
     [application registerForRemoteNotifications];
}

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
    //handle the actions
}

但是,我们的应用程序的Appstore版本不会遇到此问题,并且一切正常。 仅在企业认证上有问题吗?

[[UIApplication sharedApplication] registerForRemoteNotifications];了一个行代码: [[UIApplication sharedApplication] registerForRemoteNotifications];

像这样的东西:

if ([application respondsToSelector: selector (registerUserNotificationSettings :)]) {
      UIUserNotificationSettings * settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound
                                                                               categories: nil ];
       [[UIApplication sharedApplication] registerUserNotificationSettings: settings];
       [[UIApplication sharedApplication] registerForRemoteNotifications];
   } else {
       [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
        UIRemoteNotificationTypeBadge |
        UIRemoteNotificationTypeAlert |
        UIRemoteNotificationTypeSound];

   }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM