ios - 使用生产服务器证书向开发应用程序发送推送通知

标签 ios ssl push-notification apple-push-notifications

我们正在构建支持推送通知的应用程序。至此,我们使用沙盒模式实现了带有开发证书的推送服务器。当应用程序在应用商店发布时,Web服务器将需要使用生产证书切换到生产模式。 问题是,如果我们将服务器切换到生产环境,应用程序的开发实例是否仍然会收到推送通知?如果不是,应该怎样做才能同时在生产和开发上提供可用的推送通知?

最佳答案

当您切换到生产证书(并连接到 APNS 生产服务器)时,开发实例将不会收到推送通知。此外,尝试向开发设备 token 发送通知将导致错误(因为开发设备 token 在生产环境中无效)。在将服务器切换到生产模式之前,您应该从数据库中删除开发设备 token 。这将为您省去很多麻烦。

这是来自 here 的相关引用:

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.

Note: It is recommended that you run a separate instance of your provider for each push environment to avoid the problem of sending device tokens to the wrong environment.

如果您确实需要继续支持应用程序开发实例的推送通知,则必须在数据库中区分开发和生产设备 token (即标记哪些设备 token 是开发 token ,哪些是生产 token )。您必须使用不同的证书来维护与生产和沙箱 APNS 服务器的单独连接,并且在向设备 token 发送通知时必须使用正确的连接(基于它在数据库中的标记方式)。

关于ios - 使用生产服务器证书向开发应用程序发送推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22328919/

相关文章:

ios - Phonegap 3.5 + Facebook 插件错误它说 "FacebookSDK/FacebookSDK.h file not found"

javascript - 从 https 父窗口访问 iframe 中的 http

database - Web 服务器和数据库服务器之间的安全数据传输

ios - RNDecryptor addData 方法中的混淆

ios - 如何在 GitHub 中保存或安全避免 Facebook 或 LinkedIn 等社交网络的 key

ssl - 开发工具不显示通过 javascript 加载的不安全内容

c# - PushSharp 不发送通知

android - 如何在我们的数据库中存储设备 token 以用于推送通知?

iphone - 多个服务器上的单个 SSL 证书将推送通知发送到同一应用程序

objective-c - 无需用户点击 UITextView 即可调用 becomeFirstResponder