简体   繁体   English

"iPhone 推送通知在沙盒中有效,但在生产模式下无效"

[英]iPhone push-notification works in sandbox but not in production mode

As the title says, I have an app with built in APNS.正如标题所说,我有一个内置 APNS 的应用程序。 It does work perfectly in Sandbox-mode.它确实在沙盒模式下完美运行。 But in production-mode, it fails miserably.但在生产模式下,它惨遭失败。

It seems that I have the right certificates on the server, because I don't get an error back from the APNS-Service.看来我在服务器上有正确的证书,因为我没有从 APNS 服务收到错误消息。 Everything seems to work fine.一切似乎都很好。 I am using ApnsPHP by Aldo Armiento.我正在使用 Aldo Armiento 的 ApnsPHP。 It has a built-in function to spit out the results from the APNS-Server.它具有从 APNS 服务器吐出结果的内置功能。 When I try to use the Sandbox with the app from the store, I get - as expected - an invalid-token-error (since tokens from sandbox and production are different).当我尝试将沙盒与商店中的应用程序一起使用时,我得到 - 正如预期的那样 - 无效令牌错误(因为来自沙盒和生产的令牌不同)。 When I use the production-certificate with the app from the store, I don't get an error.当我将生产证书与商店中的应用程序一起使用时,我没有收到错误消息。 Nothing, nada, zilch - it seems like it delivered the notification.没什么,nada,zilch - 似乎它传递了通知。 Alas, it doesn't arrive on my phone.唉,它没有到达我的手机。

So apparently, the certificates must be ok.显然,证书必须没问题。 It connects to the server, it sends the notification, all passes without errors (I did have wrong certificates first, so I know what happens if they're not right :)它连接到服务器,它发送通知,所有通过都没有错误(我确实首先有错误的证书,所以我知道如果它们不正确会发生什么:)

Any ideas how to find out where the bug hides?任何想法如何找出错误隐藏的位置?

[Edit] here's what I get back from the APNS-Service: [编辑] 这是我从 APNS 服务返回的内容:

Tue, 03 Jan 2012 03:13:55 +0100 ApnsPHP[13049]: INFO: Trying ssl://gateway.push.apple.com:2195...
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: INFO: Connected to ssl://gateway.push.apple.com:2195.
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: INFO: Sending messages queue, run #1: 1 message(s) left in queue.
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: STATUS: Sending message ID 1 [custom identifier: Message-Badge-000] (1/3): 107 bytes.
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: INFO: Disconnected.

Here is three cases you can check at your end:- 以下是您可以在最后检查的三种情况: -

  1. Make sure that you have used the right production certificate on your server side. 确保您在服务器端使用了正确的生产证书。 since we need to create two different certificates for production and sandbox. 因为我们需要为生产和沙箱创建两个不同的证书。 make sure you are using correct certificate on server. 确保在服务器上使用正确的证书。

  2. second you can check that you have use the right gateway and port number on server side. 第二,您可以检查您是否在服务器端使用了正确的网关和端口号。 Since gateway for production and sandbox are different one. 由于生产和沙箱的网关是不同的。 Gateway used for production is:- gateway.push.apple.com. 用于生产的网关是: - gateway.push.apple.com。 and also you are using correct password on server for your certificate your have used on your server. 并且您在服务器上使用正确的密码作为您在服务器上使用的证书。

  3. third you can check if the notification on your device is enabled or not. 第三,您可以检查设备上的通知是否已启用。 You need to enable it on your iPhone as well. 您还需要在iPhone上启用它。 Make sure that is on your device. 确保您的设备上有。

Let me know if it works for you. 请让我知道这对你有没有用。

For me, i struggle this for days. 对我来说,我奋斗了好几天。 Using correct production certificate and key, and also correct gateway to send the message to my developing iPhone, it sent successfully in sandbox mode, but failed with production mode. 使用正确的生产证书和密钥,并正确的网关将消息发送到我正在开发的iPhone,它成功发送到沙箱模式,但生产模式失败。 It's because there are also two kinds of device token, the testing iPhone device token is sandbox token, can not be used in the production mode. 这是因为还有两种设备令牌,测试iPhone设备令牌是沙盒令牌,不能在生产模式下使用。 It's better to use another device's token to test the production APNs. 最好使用其他设备的令牌来测试生产APN。

The detailed explanation is 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 cannot 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. 如果您确实将设备令牌发送到错误的环境,则推送服务会将其视为无效令牌并丢弃该通知。

See answer in https://stackoverflow.com/a/11623162/496222 请参阅https://stackoverflow.com/a/11623162/496222中的答案

In short: make sure both SSL certificates are in a separate PEM file. 简而言之:确保两个SSL证书都在一个单独的PEM文件中。 Having a single PEM file with both sandbox and production certificate will cause either environment to fail. 拥有包含沙盒和生产证书的单个PEM文件将导致任一环境失败。

另请检查您的App Id是否启用了推送通知

This solved my issue, ensure setting correct value for kGGLInstanceIDAPNSServerTypeSandboxOption . 这解决了我的问题,确保为kGGLInstanceIDAPNSServerTypeSandboxOption设置正确的值。 For Development mode set to YES and For production mode 'NO'. 开发模式设置为YES,生产模式设置为“NO”。

Hi did you try to check your entitlement plist?嗨,您是否尝试检查您的权利清单? Change APS Environment in Entitlements.plist to "production".将 Entitlements.plist 中的 APS 环境更改为“生产”。 see the photo screenshot here<\/a>在这里查看照片截图<\/a>

"

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

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