【问题标题】:Push notifications on iOS 8 and iOS 9 using Enterprise distribution使用企业分发在 iOS 8 和 iOS 9 上推送通知
【发布时间】:2016-05-24 11:53:04
【问题描述】:

我为一家公司创建了一个应用程序,他们希望通过 Enterprise 为他们的员工分发该应用程序。当他们使用 iOS 9 版本的手机执行此操作时,它就像一个魅力,但对于 iOS 8,他们永远不会提示“允许推送通知”,因此应用程序永远不会收到任何通知。我查看了手机设置中的通知,默认是开启的。

我尝试将其设置为禁用,确保应用已终止,然后将其添加回启用并启动应用。我已尝试删除该应用程序,重新安装它,重新启动并再次尝试所有步骤,但它不起作用。

有人有什么想法吗?

编辑

我现在得到了提示。不过,我仍然没有收到任何通知...我有两台装有 iOS 8 的设备,它们都没有收到通知,我有两台装有 iOS 9 的设备,它们都收到了通知。

【问题讨论】:

    标签: ios apple-push-notifications enterprise


    【解决方案1】:

    如果你真的想看到通知提醒, 来自 Apple Doc [https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG42] 它说,

    支持推送的应用首次注册推送通知时,iOS 会询问用户是否希望接收该应用的通知。一旦用户对此警报做出响应,除非设备已恢复或应用已卸载至少一天,否则它不会再次显示。

    但如果你想立即检查,只需做几件事

    1. 从设备中删除您的应用。
    2. 完全关闭设备,然后重新打开。
    3. 转到设置 > 常规 > 日期和时间,然后将日期提前一天或更长时间。
    4. 再次完全关闭设备,然后重新打开。

    但是,这样做你会收到一个接受接收通知的提醒。

    根据您的说法,由于推送通知默认开启(或之前已接受),您应该会收到通知。

    请发表评论。

    【讨论】:

    • 我这样做了,现在得到了提示。但我仍然没有收到任何通知......但它在 iOS 9 上运行良好。
    • @ClockWise if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]] ; [[UIApplication sharedApplication] registerForRemoteNotifications]; } 用这个。或者让 settings = UIUserNotificationSettings(forTypes: .Alert, categories: nil) UIApplication.sharedApplication().registerUserNotificationSettings(settings)
    • 感谢@user3487853 的努力,但其中一半甚至不是快速代码。
    • 请检查最后几行用 swift 编写的代码。 @ClockWise
    【解决方案2】:

    你必须这样设置

    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:
                                            (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound)
                                                                             categories:categories];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    

    检查用户是否允许系统设置的本地通知

    /**
     *  check if user allow local notification of system setting
     *
     *  @return YES-allowed,otherwise,NO.
     */
    + (BOOL)isAllowedNotification {
        //iOS8 check if user allow notification
        if ([UIDevice isSystemVersioniOS8]) {// system is iOS8
            UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
            if (UIUserNotificationTypeNone != setting.types) {
                return YES;
            }
        } else {//iOS7
            UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
            if(UIRemoteNotificationTypeNone != type)
                return YES;
        }
    
        return NO;
    }
    

    【讨论】:

    • 感谢您的帮助,您是否有 swift 版本?忘记在OP中提及。我现在收到了提示,但我没有收到任何通知,这可能是因为您在此处编写的代码。将尝试将其转换为 swift。
    猜你喜欢
    • 2014-04-01
    • 2013-03-28
    • 2017-05-24
    • 2014-11-14
    • 1970-01-01
    • 2015-01-17
    • 1970-01-01
    • 2012-01-16
    • 1970-01-01
    相关资源
    最近更新 更多