即席分发中的推送通知问题

发布于 2024-12-09 12:52:18 字数 133 浏览 5 评论 0原文

你好,我是 iPhone 新手。

我正在开发 Iphone 应用程序,该应用程序在开发环境中成功接收推送通知,但在临时分发中没有收到通知。

我拥有两个证书,即开发证书和证书生产。

谁能告诉我我错过了什么?

Hello I am new to IPhone.

I am working on Iphone app which receives push notifications successfully with development environment,but didn't receive notifications in adhoc distribution.

I have both certificates i.e development & production.

Can anyone tell me what am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

み青杉依旧 2024-12-16 12:52:18

正如我昨天发布的对同一问题的回答:(prev . 回答)

我也有类似的问题。经过一些测试后,我得出以下结论:

  1. 如果安装了应用程序(使用开发配置文件编译),则此类设备具有开发令牌,并且您应该发送使用开发证书推送到此类设备。

  2. 如果安装了应用程序(使用分发配置文件编译),则此类设备具有生产令牌,并且您应该使用生产证书将推送发送到此类设备

而且,如果您的应用程序尚未发布,我认为 APNS 不会接受生产证书,因此您可能无法将推送发送到您的临时应用程序应用程序。

你能做什么?例如,将使用开发证书编译的应用程序发送给您的测试人员。

更新:
我再次了解了这个问题,并发现了一些有趣的信息:

  1. 下载您的临时配置文件
  2. 使用文本编辑器打开 1. 中的配置文件。
  3. 搜索线路
    aps-environment;
    product
  4. 检查键 aps-environment 的值。它是否等于生产?
  5. 如果是,那么您应该向您的临时应用程序发送带有生产证书的推送通知。

    如果值为development,那么您应该向您的临时应用程序发送带有开发证书的推送通知。

  6. 现在打开iOS Provisioning Portal -> 应用 ID。选择您的应用程序。
  7. 检查是否启用了生产推送 SSL 证书

如果这对您没有帮助,请尝试更新您的临时配置文件。

As I posted yesterday as answer to the same question: (prev. answer)

I've similar problems. After making some test I reached the following conclusions:

  1. If app (that was compiled with development provision profile) is installed than such device has development token and you should sent pushes to such device using development certificate.

  2. If app (that was compiled with distribution provision profile) is installed than such device has production token and you should sent pushes to such device using production certificate.

And, If your app is not yet published, I think that APNS will not accept production certificate, so probably you won't be able to send push to your ad-hoc apps.

What you can do? For example, sent app to your testers that compiled with development certificate.

UPDATED:
I've learned this question one more time and found some interesting information:

  1. Download your Ad-hoc provision profile.
  2. Open provision profile from 1. with text editor.
  3. Search for lines
    <key>aps-environment</key>
    <string>production</string>
  4. Check the value of the key aps-environment. Is it equal to production?
  5. If yes then you should send to your ad-hoc apps push notification with production certificate.

    If the value is development then you should send to your ad-hoc apps push notification with development certificate.

  6. Now open iOS Provisioning Portal -> App IDs. Select your app.
  7. Check if Production Push SSL Certificate is enabled.

If this didn't help you then try to update your ad-hoc provisioning profile.

抚你发端 2024-12-16 12:52:18

在测试开发环境的推送通知时,应牢记一些严格的清单。其中大部分已经在上面提到过。但这是解决我问题的一件事,我想分享。我希望它能帮助某人。即:

请注意设备令牌 ID,它对于开发者来说是不同的。生产环境。

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
       NSString *deviceTokenStr = [[[[deviceToken description]
                                      stringByReplacingOccurrencesOfString: @"<" withString: @""]
                                     stringByReplacingOccurrencesOfString: @">" withString: @""]
                                    stringByReplacingOccurrencesOfString: @" " withString: @""];
       UIAlertView *alert= [[UIAlertView alloc]initWithTitle:deviceTokenStr message:Nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
}

There are severeral checklist that one should keep in mind while testing pushnotification for development environment. Most of them are already mentioned above. But this is one thing THAT SOLVED MY PROBLEM and i would like to share. I hope it helps someone. And that is:

Please be aware of the device token-ID, which is different for the development && Production environment .

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
       NSString *deviceTokenStr = [[[[deviceToken description]
                                      stringByReplacingOccurrencesOfString: @"<" withString: @""]
                                     stringByReplacingOccurrencesOfString: @">" withString: @""]
                                    stringByReplacingOccurrencesOfString: @" " withString: @""];
       UIAlertView *alert= [[UIAlertView alloc]initWithTitle:deviceTokenStr message:Nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
}
南巷近海 2024-12-16 12:52:18

推送通知有时令人头痛,并且由许多元素组成。如果您在途中错过了某些内容,您的 PNS 将无法工作,并且很难理解原因。根据经验,请查看以下清单:
- 使用正确的应用程序 ID(与配置文件所附加的应用程序 ID 相同)正确生成了推送证书和私钥。
- 证书和私钥均取自同一个下载的 PNS 证书。
- 两个文件都正确连接成 .pem 文件。
- 您的应用程序在应用程序处于活动状态时处理传入的推送通知。

在任何情况下,我建议遵循一个很好的教程,例如:http://mobiforge.com/developing/story/programming-apple-push-notification-services 逐字逐句。祝你好运!

Push notifications are a headache sometimes and are made up of many elements. If you miss something on the way, your PNS won't work and it will be very difficult to understand why. As a rule of thumb, view the following checklist:
- Push certificate and private key were generated correctly with the correct App ID (the same one that the provisioning profile is attached to).
- Both the certificate and private key are taken from the same, downloaded PNS certificate.
- Both files were correctly concatenated into a .pem file.
- Your application handles push notifications as they come in, while the app is active.

In any case, I recommend following a good tutorial, such as this: http://mobiforge.com/developing/story/programming-apple-push-notification-services word for word. Good luck!

以可爱出名 2024-12-16 12:52:18

我遇到了同样的事情,并花了相当长的时间试图弄清楚。我生成了一个新的生产证书,创建了一个临时配置文件(以便我可以通过生产过程中的推送通知进行测试),但没有任何效果。

我相应地修复了推送脚本(服务器端)(使用新生成的 .pem 文件并连接到 ssl://gateway.push.apple.com:2195)。该脚本告诉我通知已发送,但我的设备实际上并未收到通知。

事实证明这个问题真的很愚蠢!显然,当使用具有新证书的应用程序时,设备令牌会发生变化(无论是通过新证书还是通过 Ad-Hoc)。我只能推测它们改变的原因,但我所知道的是,一旦我获取了正确的令牌并使用我的测试脚本向设备发送通知,我就明白了!

I ran into the same thing and spent quite some time trying to figure it out. I generated a new production certificate, created an Ad-Hoc provisioning profile (so that I could test with the push notification going through production) and nothing was working at all.

I fixed the push script (server-side) accordingly (using the new generated .pem files and connecting to ssl://gateway.push.apple.com:2195). The script was telling me that the notification was delivered but my device wasn't actually getting it.

Turns out the problem was really silly! Apparently the device tokens change when using the application with the new certificate (either that or through Ad-Hoc). I can only speculate the reason as to why they changed, but all I know is that once I grabbed the correct token and used my test script to send a notification to the device, I got it!

心头的小情儿 2024-12-16 12:52:18

除了 Nekto 的猜测之外……

而且,如果您的应用程序尚未发布,我认为 APNS 不会接受生产证书,因此您可能无法将推送发送到您的临时应用程序。

与此同时,我可以确认即使应用程序尚未发布,也可以在临时应用程序上接收推送通知。

In addition to the guess from Nekto...

And, If your app is not yet published, I think that APNS will not accept production certificate, so probably you won't be able to send push to your ad-hoc apps.

In the meantime I can confirm that it is possible to receive push notifications on ad-hoc apps, even if the app is not published yet.

油饼 2024-12-16 12:52:18

据我了解,您无法使用开发证书向 Ad Hoc 版本发送通知。正如您可以想象的那样,在您发布应用程序之前,这种情况是可以的。应用程序发布后,向包含生产证书的临时构建发送通知也会将它们发送给您的应用程序持有者。我解决这个问题的方法是:

  1. 在Apple中创建一个与itunes中的应用程序具有相同基线的新应用程序。
  2. 为此“幻影”应用程序创建新的生产密钥和证书。
  3. 使用新的生产密钥构建新应用程序并使用该构建进行测试。

现在您将拥有一个可以构建的应用程序来专门测试通知。这不是一个优雅的解决方案,但它确实有效。

As I understand it, you cannot send notifications to an Ad Hoc build with a development certificate. As you can imagine this scenario is ok UNTIL you release the app. Once the app is released sending notifications to the ad hoc build containing the production Cert will also send them out to your app holders. The way I got around this was:

  1. Create a new app in Apple that is the same baseline as the app in itunes.
  2. Create a new production key and cert for this "phantom" app.
  3. Build the new app with the new production key and test with that build.

Now you will have an app you can build to specifically test notifications. Not an elegant solution but it works.

家住魔仙堡 2024-12-16 12:52:18

我刚刚克服了一个非常相似的问题,结果证明它可能应该是显而易见的,但我会将其发布在这里,以防其他人像我一样愚蠢。

我正在使用 MoonAPNS 并且可以接收开发通知,但不能接收生产通知。
经过几天的兜圈子后,我回到了这一行:

PushNotification push = new PushNotification(true, p12file, p12password);

之前忽略了 true 参数,通过服务器代码进行调试显示这是设置是否使用沙盒服务器 - D'Oh !将其切换为 false 一切正常。

这个故事的寓意是:不要忘记将您的通知指向非沙盒服务器!

I have just overcome a very similar problem and it turned out to be something that probably should've been obvious but I'll post it here just in case anyone else is as daft as me.

I'm using MoonAPNS and could receive development notifications but not production.
After several days of going around in circles I came back to this line:

PushNotification push = new PushNotification(true, p12file, p12password);

Having previously disregarded true parameter, a debug through the server code showed this was setting whether or not to use the Sandbox server - D'Oh! Switched it to false and all was well.

Moral of the story: don't forget to point your notifications at the non-Sandbox server!

满栀 2024-12-16 12:52:18

我也遇到了同样的问题,经过大量的睾丸检查后,我终于明白了问题所在。

这是因为苹果生产的apns服务器不再允许包含私钥数据的P12文件。但是开发 apns 服务器将接受包含私钥的 P12 文件。

因此,当您从钥匙串导出 P12 文件时,只需选择不带私钥的生产证书文件,您就会在临时应用程序上收到通知(即使未发布)。

I got the same issue and after a lots of testes finally i had got what's the problem.

That's because the apple production apns server not allow the P12 file that contain the data of private key any more. But the development apns server will accept the P12 file what ever if contain the private key.

So when you export the P12 file from keychain just only select your Production Certificate file without the private key and you will got the notifications on your adhoc app (even if not published).

穿越时光隧道 2024-12-16 12:52:18

2016.10.13 的回答

我在更改以下教程的密钥后遇到了类似的问题:
https://support.magplus .com/hc/en-us/articles/203808718-iOS-Creating-a-Push-Notification-Certificate

但仍然无法工作
检查服务器代码后发现

ssl: ssl://gateway.sandbox.push.apple.com:2195
必须更改为 ssl://gateway.push.apple.com:2195

更改后,我可以收到通知

Answer for 2016.10.13

I have similar issue that after I change key following tutorial:
https://support.magplus.com/hc/en-us/articles/203808718-iOS-Creating-a-Push-Notification-Certificate

But still couldn't work
After I check server code and found that

The ssl: ssl://gateway.sandbox.push.apple.com:2195
Must be change to ssl://gateway.push.apple.com:2195

After change that, I can receive notification

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文