简体   繁体   English

推送通知问题iOS TestFlight

[英]Push Notifications problems iOS TestFlight

I'm trying to get a few friends of mine to test my app on TestFlight. 我试图让我的几个朋友在TestFlight上测试我的应用程序。 This all is going fine except for the Push notifications. 除了“推送”通知之外,其他一切都很好。 I do not seem to be able to extract their Push tokens. 我似乎无法提取其Push令牌。 I've double checked and they've granted the app permission to take the Push token. 我已仔细检查,他们已授予应用程序使用Push令牌的权限。

In my opinion this all looks fine: 我认为一切都很好:

在此处输入图片说明

在此处输入图片说明

Apple does however send the following e-mail after I upload the app to TestFlight: 但是,在我将应用程序上传到TestFlight之后,Apple确实发送了以下电子邮件:

Missing Push Notification Entitlement - Your app includes an API for Apple's Push Notification service, but the aps-environment entitlement is missing from the app's signature. 缺少推送通知权利-您的应用程序包含Apple推送通知服务的API,但是应用程序签名中缺少aps环境权利。 To resolve this, make sure your App ID is enabled for push notification in the Provisioning Portal. 要解决此问题,请确保在Provisioning Portal中为您的App ID启用了推送通知。 Then, sign your app with a distribution provisioning profile that includes the aps-environment entitlement. 然后,使用包含aps-environment权利的发行配置文件对您的应用程序进行签名。 This will create the correct signature, and you can resubmit your app. 这将创建正确的签名,您可以重新提交您的应用程序。 See "Provisioning and Development" in the Local and Push Notification Programming Guide for more information. 有关更多信息,请参见《本地和推送通知编程指南》中的“ Provisioning and Development”。 If your app does not use the Apple Push Notification service, no action is required. 如果您的应用程序不使用Apple Push Notification服务,则无需采取任何措施。 You may remove the API from future submissions to stop this warning. 您可以从以后的提交中删除该API,以停止此警告。 If you use a third-party framework, you may need to contact the developer for information on removing the API. 如果使用第三方框架,则可能需要与开发人员联系以获取有关删除API的信息。


I am able to extract my own device's Push token when downloading a fresh copy from TestFlight. 从TestFlight下载新副本时,我能够提取自己设备的Push令牌。
I've no idea what's going on and would really like to fix this. 我不知道发生了什么,真的很想解决这个问题。 Can anyone help me out? 谁能帮我吗?
In case it helps. 万一有帮助。 This is my code: 这是我的代码:

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
    var tokenString = ""

    for i in 0..<deviceToken.length {
        tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
    }

    Constant.pushToken = tokenString

    if (KeychainWrapper.hasValueForKey("user_id")){
        let user = User()
        user.id = Int(KeychainWrapper.stringForKey("user_id")!)!
        ApiManager.sharedInstance.putPushToken(user){ (result, error) -> Void in
            if error != nil {
                //error
            } else {
                //success
            }
        }
    }
}

You need to add an entitlements file for this. 您需要为此添加权利文件。 In your case, somehow its not attached with your project when you have enabled push notifications from Capabilities . 在您的情况下,从Capabilities启用推送通知后,它不以某种方式与您的项目关联 Please Turn off and turn on Push Notifications option. 请关闭并打开“推送通知”选项。 You may get the entitlements file added automatically in your project. 您可能会在项目中自动添加权利文件。

在此处输入图片说明

Update : Is server using the sandbox url or the disribution url ? 更新:服务器是使用沙箱 URL还是分发URL?

确保使用分发配置文件进行归档以进行TestFlight beta测试。

  • Check the service which you have been using for Push notification. 检查您用于推送通知的服务。

  • Check if you have registered for the Notification service for Badge|Sound|Alert. 检查您是否已经注册了Badge | Sound | Alert的通知服务。

  • Add a debugger at receivedRemoteNotification and check if you are being able to get the notification. 在receiveRemoteNotification处添加调试器,并检查是否能够获取通知。

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

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