iOS 推送通知在开发中有效,但在生产中无效

发布于 2024-12-14 03:00:57 字数 794 浏览 0 评论 0原文

首先我要说的是,我已经花了几个小时寻找解决方案。我读过几乎所有与此相关的问题,但没有一个解决方案有效。我还阅读了有关该主题的官方苹果文档和其他一些教程。基本上我这样说是为了避免明显的建议,例如(确保它不是“沙箱”等)。

我在配置门户中拥有我的应用程序的开发和产品推送通知证书。我已按照步骤使用苹果自己的文档创建 dev 和 prod 的 pem 文件。

我有与此应用程序绑定的开发和临时分发配置文件。

我可以使用开发配置文件直接从 xcode 构建我的应用程序到设备,也可以使用临时分发配置文件将其存档(然后我使用 beta 构建器安装到设备上)。

无论我是直接使用开发配置文件构建还是使用临时配置文件(通过 beta 构建器)构建,推送通知在使用沙箱 + 开发 pem 文件时都会起作用。但是,一旦我使用 prod 服务器 + prod pem 文件进行测试,就不会发送推送通知。

我有两个用于测试的 php 脚本,一个用于开发,一个用于生产。除了服务器 URL(沙箱与非沙箱)和引用的 pem 文件(dev 或 prod)之外,它们本质上是相同的。

我觉得很奇怪,即使使用临时构建,我仍然可以使用沙箱和开发 pem 发送推送通知,这是正常的吗?

从开发转向产品时我还应该做些什么吗?我觉得此时我已经尝试了一切。我已经多次重新生成证书和配置文件。我遵循几乎完全相同的过程来生成 dev 和 prod pem 文件以及我的 php 脚本,并且几乎相同(对于 prod 和 dev)。

我不知道这是服务器问题还是客户端(应用程序)问题?有什么地方我可能会忘记吗?

我希望有人能阐明这一点,因为它开始让我发疯!

干杯。

First let me say that I've been searching to find a solution for a few hours now. I've read almost every SO question regarding this and none of the solutions have worked. I've also read the official apple docs on the subject and a few other tutorials. Basically I'm saying this to avoid the obvious suggestions like (make sure it's not "sandbox", etc).

I have both dev and prod push notification certificates for my app in the provisioning portal. I've followed the steps to create a pem file both dev and prod using apple's own documentation.

I have both dev and ad hoc distribution provisioning profiles tied to this app.

I can build my app either directly from xcode to device using the dev profile or archive it using the ad hoc distribution profile (I then use beta builder to install onto the device).

Whether I build directly with the dev profile or using the ad hoc profile (via beta builder) the push notifications work when using the sandbox + dev pem file. But as soon as I test using the prod servers + prod pem file the push notifications aren't sent.

I have two php scripts for testing, one for dev, one for prod. They are essentially identical except for the server url (sandbox vs not sandbox) and the pem file that is referenced (dev or prod).

I find it strange that even with the ad hoc build I can still send push notifications using the sandbox and dev pem, is this normal?

Is there anything else I should maybe do when going from dev to prod? I feel like I've tried everything at this point. I've re-generated the certificates and profiles many times. I follow almost the exact same procedure for generating the dev and prod pem files and my php scripts and nearly identical (for prod and dev).

I have no idea if this is a server issue or a client (app) issue? Is there a setting somewhere I may be forgetting?

I hope that someone can shed some light on this as it's starting to drive me crazy!

Cheers.

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

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

发布评论

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

评论(2

梦年海沫深 2024-12-21 03:00:57

好吧,我发现了问题,这对我来说是一个愚蠢的错误。我会在这里分享,以防其他人犯同样的错误。

我不知道的关键是开发和生产的设备令牌是不同的(对于同一设备)。我使用在开发中测试时获得的设备令牌在产品中进行测试。这在开发中工作得很好,但是当我切换到产品时,我在 php 脚本中保留了相同的设备令牌(错误地假设同一设备的设备令牌是相同的),但在产品中注册的实际设备令牌是不同的。

实际上,当设备令牌发送到服务器时,这种情况不会发生,但当我测试时,我使用硬编码设备令牌,因为我不想涉及服务器。

希望这能减轻一些人的挫败感。

Well I found the problem, it was a silly mistake on my end. I'll share here in case someone else made the same mistake.

The key thing I didn't know is that the device token is different for dev and prod (for the same device). I was using the device token I got when testing in dev to test in prod. This was working fine in dev, but when I switched to prod I kept the same device token in the php script (assuming, wrongfully, that the device token would be the same for the same device) but the actual device token registered in prod was different.

In practice this wouldn't happen as the device token is sent to the server, but when I was testing I was using hard coded device token as I didn't want to involve the server.

Hopefully this will save someone some frustration.

早乙女 2024-12-21 03:00:57

类似的问题也发生在我身上,我将推送通知添加到现有的应用程序中,通过使用 Xcode 在我的设备上运行进行测试,效果很好,但是当创建存档并通过 iTunes 安装时,它没有收到推送通知。
问题是,当我添加推送通知的权限时,我的配置文件已过时(无效),因此我必须生成新的配置文件,应用于我的 iTunes/手机,现在当我安装应用程序时,它运行良好。

Similar issue happen to me, I added Push Notifications to an existent app, tested by running using Xcode to my device and it worked well, but when when created the Archive and installed via iTunes, it didn't receive Push Notifications.
The problem was that when I added the permissions for push notifications, my Provisioning Profile got obsolete (Invalid), so I had to generate a new Provisioning Profile, apply to my iTunes/phone, and now when I install the app it works well.

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