苹果推送通知在生产中不起作用 [英] apple push notification not working in production

查看:35
本文介绍了苹果推送通知在生产中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们完全被困住了,请帮忙.

We are totally stucked, please help.

我和我的团队制作了一个 iPhone 应用程序,这是我们第一次在 iOS 上尝试.

I and my team made a iPhone application, and this is the first time we try on iOS.

一切都很好,直到我们提交了我们的应用程序并在应用程序商店上架 - 推送通知服务不起作用.我在网上搜索并尝试根据人们的建议仔细检查我们的应用程序,但我找不到问题所在.所以这个问题发布在这里.

Everything is fine, until we submitted our app and became available on app-store -- the push notification service is not working. I searched around the web and tried double check on our app by people's advices, but I couldn't find what's wrong. so this question is posted here.

这些是我们所做的:

  1. 我们构建应用程序,假设它名为AppMaster".

  1. We build the application, suppose it's named "AppMaster".

我们在名为pushtest"的 iOS 配置门户上创建了 AppId.此 ID 在开发和生产中都启用了推送通知.

We created AppId on iOS Provisioning Portal called: "pushtest". This ID enabled the Push Notification on both development and production.

我们从上面的 appId 创建了一个名为AppMasterPushTest"的开发配置.此配置用于内部测试,团队中的每个人都在他们的 Mac 上安装了它.

We created a Provisioning for development named "AppMasterPushTest" from the appId above. This provisioning is for inside test, everyone of the team installed it on their mac.

我们的服务器是由 Java 实现的,我们使用了 java-apn 包.在测试过程中,我们下载了用于开发的认证文件并写出了 .p12 文件,并通过使用包的 api -- withSandboxDestination() 和该 .p12 文件将我们的消息推送到沙箱"服务器.测试顺利,收到通知.

Our server is implemented by Java and we used the java-apn package. during the test, We downloaded the certification file for development and write out the .p12 file, and pushed our message to the "sandbox" server by using the package's api -- withSandboxDestination() with that .p12 file. test goes fine, notifications are received.

我以为我们已经准备好了,所以我们创建了另一个名为AppMaster"的 AppId,并且只为生产启用推送通知.此 ID 写在应用程序的包标识符中.

I thought we were ready, so we created another AppId called "AppMaster", and enable Push Notification only for production. This Id is written in the app's bundle identifier.

我们在第 5 步中从 AppId 为生产创建了另一个名为appMaster"的 Provisioning,分发方法设置为App Store".下载并重建应用程序.这个提交给了苹果,并在 app-stroe 上活跃起来.

We made another Provisioning for production named "appMaster" from AppId in step 5, with distribution method set as "App Store". downloaded it and rebuild app. This one was submitted to apple, and goes alive on app-stroe.

服务器端,我们下载了生产认证,重新写出.p12文件.并使用api-withProductionDestination()制作了将消息推送到生产服务器的程序,.p12刚刚写出来.

Server side, We downloaded the certification for production and write out the .p12 file again. and made program to push message to production server by using the api -- withProductionDestination(), with the .p12 just been write out.

我们从 App Store 安装了该应用.遗憾的是,通知从未送达.

We installed the app from App Store. sadly, the notification was never delivered.

我们错过了什么吗?顺便说一句,我们在 step5 中创建的 id 看起来像XXX.com.company.appname",但是在应用程序的包标识符中,我们只设置了com.company.appname"部分而没有前缀.这可能是问题吗?

Is there something we missed? BTW, the id we created in step5 was looks like "XXX.com.company.appname", but in the app's bundle identifier, we just set "com.company.appname" part without prefix. is this could be the problem?

欢迎任何想法.

请成为我们的保护者.谢谢.

please be our saver. thanks.

推荐答案

以上评论不正确.应用 ID 在捆绑 ID 之前有一个前缀:

The comment above is incorrect. The app ID has a prefix before the bundle ID :

应用程序 ID 由应用程序的捆绑 ID 组成,前缀为Apple 生成的十个字符的代码.团队管理员必须输入捆绑 ID.对于证书,它必须包含一个特定的包ID;您不能使用通配符"应用程序 ID.

An application ID consists of an application’s bundle ID prefixed with a ten-character code generated by Apple. The team admin must enter the bundle ID. For a certificate, it must incorporate a specific bundle ID; you cannot use a "wildcard" application ID.

您应该检查您的配置文件,以确保它包含正确的 aps 权限:

You should check your provisioning profile, to make sure it contains the correct aps entitlement :

验证供应配置文件中的权利是正确的.为此,请在文本编辑器中打开 .mobileprovision 文件.文件的内容以 XML 结构化.在权利字典找到 aps-environment 键.为开发配置文件,这个键的字符串值应该是发展;对于分发配置文件,字符串值应该是生产.

Verify that the entitlements in the provisioning-profile file are correct. To do this, open the .mobileprovision file in a text editor. The contents of the file are structured in XML. In the Entitlements dictionary locate the aps-environment key. For a development provisioning profile, the string value of this key should be development; for a distribution provisioning profile, the string value should be production.

在向生产 APNS 服务器发送推送通知时,您应该确保使用生产设备令牌(在沙盒环境中工作的设备令牌在生产环境中不起作用).

You should make sure you are using production device tokens when sending push notifications to the production APNS server (device tokens that works in the sandbox environment don't work in the production env).

在将应用发布到应用商店之前,您应该已经使用 AdHoc 配置文件对其进行了测试.AdHoc 配置文件适用于生产推送环境.

You should have tested your app with an AdHoc provisioning profile prior to releasing it to the app store. The AdHoc profile works with the production push environment.

关于设备令牌的一些引用:

Some quotes regarding device tokens :

来自 本地和推送通知编程指南 :

注意生产环境中的设备令牌和开发(沙盒)环境中的设备令牌不一样价值.

Take note that the device token in the production environment and the device token in the development (sandbox) environment are not the same value.

来自 技术说明 TN2265:

处理格式错误的通知

如果推送服务,简单的二进制接口会断开连接收到以某种方式不正确的通知.您的提供商可能会将此视为 EPIPE 或管道损坏错误以响应发送通知.另一方面,增强的二进制接口将发送包含更详细信息的错误响应在断开连接之前通知错误.确定您的提供商会正确捕捉并处理这些情况.

The simple binary interface drops the connection if the push service receives a notification that is incorrect in some way. Your provider may see this as an EPIPE or broken pipe error in response to sending a notification. On the other hand, the enhanced binary interface will send an error response with more detailed information about what was wrong with the notification before dropping the connection. Be sure your provider catches and handles these conditions properly.

最常见的问题是无效的设备令牌.如果令牌来了从沙箱环境中,例如当您测试内部开发构建,您无法将其发送到生产推送服务.每个推送环境都会为相同的设备或计算机.如果您确实将设备令牌发送到错误的环境,推送服务会将其视为无效令牌,并且放弃通知.

The most common problem is an invalid device token. If the token came from the sandbox environment, such as when you are testing a development build in house, you can't send it to the production push service. Each push environment will issue a different token for the same device or computer. If you do send a device token to the wrong environment, the push service will see that as an invalid token and discard the notification.

最后,这篇文章对当某些通知无效(最常见的原因是设备令牌无效)时,向 Apple 发送多个通知如何会导致某些有效通知也无法到达.

Finally, this article has a good explanation of how sending multiple notifications to Apple when some of the notifications are invalid (the most common cause being invalid device tokens), can cause some of the valid notifications not to arrive as well.

这篇关于苹果推送通知在生产中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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