推送通知未在 IOS8.1 中提供,但在少于 IOS8.1 时工作正常

Posted

技术标签:

【中文标题】推送通知未在 IOS8.1 中提供,但在少于 IOS8.1 时工作正常【英文标题】:Push Notification Not delivered in IOS8.1 but working fine in less then that 【发布时间】:2014-11-18 08:00:26 【问题描述】:

更新:请注意我使用的是 Xcode 6.01 并使用此代码进行部署,但它不起作用,但是当我安装 Xcode 6.1 版本并部署它工作的代码时...所以它可能是 Xcode 版本问题会帮助别人。

我正在使用以下代码使用 PARSE.com 进行推送通知,它在 ios8 以下的所有设备中都可以正常工作,

if (application.applicationState != UIApplicationStateBackground) 
        // Track an app open here if we launch with a push, unless
        // "content_available" was used to trigger a background push (introduced in iOS 7).
        // In that case, we skip tracking here to avoid double counting the app-open.
        BOOL preBackgroundPush = ![application respondsToSelector:@selector(backgroundRefreshStatus)];
        BOOL oldPushHandlerOnly = ![self respondsToSelector:@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)];
        BOOL noPushPayload = ![launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) 
            [PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
        
    
    

我也用这些条件进行测试(在低于 ios 8 的情况下工作正常

如果 __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) 
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                    UIUserNotificationTypeBadge |
                                                    UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                             categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];
 else

endif


    [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                     UIRemoteNotificationTypeAlert |
                                                     UIRemoteNotificationTypeSound)];

即使iOS 8 enabled device not receiving PUSH notifications after code update 不适合我 我正确设置了通知,我的捆绑标识符设置也正确

【问题讨论】:

你得到设备令牌了吗? 是的,即使在 parse.com 中,我也知道推送正在传递,但在我的设备(iPhone/ipad 两者)的 IOS 8.1 中,我没有收到任何通知 【参考方案1】:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];

else

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];

【讨论】:

我认为这个链接会帮助你更多。 ***.com/questions/25909568/…

以上是关于推送通知未在 IOS8.1 中提供,但在少于 IOS8.1 时工作正常的主要内容,如果未能解决你的问题,请参考以下文章

推送通知未在 iOS 10 设备中显示

推送通知未在 Android 前台显示

带有自定义声音的推送通知未在 iOS 中显示

当应用程序在前台 iOS 中时,未在通知托盘(顶部)中获取推送通知

当应用程序未运行时,GCM 推送通知未在某些设备中显示

使用 Sinch 的即时消息推送通知未在 iOS 上提供