Back4App 和 APN 身份验证密钥的推送通知问题

发布于 2025-01-12 02:44:40 字数 1226 浏览 6 评论 0原文

我将 ParseServer 与 Back4App 一起用于 Android 和 iOS 应用程序。我在服务器上实现了一个云函数,通过 Parse 发送推送通知,它适用于 Android 应用程序,没有任何问题(对于调试和生产 apk)。

使用 iOS 版本,我目前遇到以下问题: 我创建了一个 APN 身份验证密钥,并将其上传到 Back4App。在此过程中,我指出此键用于调试应用程序,并且通过 Cloud Function 向我的 iOS 调试设备发送推送通知就像一个魅力,无论什么设备触发 Cloud Function。这对于发展来说已经足够了。

我需要能够向两种设备类型获取推送通知,以便在我最近开始的开放测试中与我的 TestFlight 测试人员一起进行故障排除。

对于所有 TestFlight 测试设备,都不会发送推送通知 - 这并不奇怪,因为 APN 密钥已上传到 Back4App 仅用于调试应用程序。

因此,我重新上传了 APN 密钥并表明它是一个生产应用程序,现在向 TestFlight 测试人员发送推送通知可以工作,但向我的 iOS 调试测试设备发送推送通知则不行。

我尝试通过将 Xcode 中的构建方案从“调试”更改为“发布”来解决此问题 - 但对于我的 iOS 调试设备上的发布版本,推送通知仍然不会传递到所述设备。我可以在我的 Parse Dashboard 中看到它们正在被发送,但它们没有被传递。

我正在使用通知服务扩展并将构建模式设置为发布,但没有效果。

将 Back4App 上的 APN 身份验证密钥更改回“调试”仅允许我在调试设备上再次接收推送通知。

我尝试更改 APN 身份验证密钥(对于调试和生产,因为我无法在 Back4App 上选择两者),然后强制退出应用程序,重新启动应用程序以将新的 APN 令牌保存到 ParseServer,然后发送测试通知,也发送到没有用。我在我的调试设备和 TestFlight 设备上都尝试过此操作,并且始终是我的调试设备(直接从 Xcode 获取应用程序)或 TestFlight 设备能够接收推送通知,而不是两者都接收。

我没有抽出时间尝试使用 APN 证书,因为我读到有两个不同的证书用于生产和调试应用程序。虽然 Back4App 可以实现这一选项,但仍然存在一个大问题 - 如何仅使用一个 APN 身份验证密钥在 iOS 中实现调试和生产应用程序的推送通知?更具体地说,您如何在 Back4App 上做到这一点?

或者除了旧的 APN 证书之外还有其他方法解决此问题吗?由于 APN 身份验证密钥被认为是未来的趋势,我宁愿用它来实现它,而不是旧的 APN 证书。

感谢任何帮助,提前致谢!

I'm using ParseServer with Back4App for an Android and iOS App. I implemented a Cloud Function on the server to send push notifications through Parse and it works for the Android app without any issues (for both debug and production apks).

With the iOS Version I am currently running into the following problem:
I created an APN Authentication Key that I uploaded to Back4App. In the process I indicated that this key is for a debug app, and sending push notifications via the Cloud Function to my iOS debug device works like a charm, no matter what device triggers the Cloud Function. This was sufficient for development.

I need to be able to get push notifications to both device types to troubleshoot together with my TestFlight testers in an open test I recently started.

For all TestFlight test devices, push notifications are not getting delivered - which is not surprising, given that the APN Key was uploaded to Back4App for debug apps only.

I thus reuploaded the APN Key and indicated that it is a production app, and now sending push notifications to the TestFlight testers works, but sending push notifications to my iOS debug test device does not.

I tried getting around this by changing the build scheme in Xcode from Debug to Release - but with a release version on my iOS debug device, the push notifications are still not being delivered to said device. I can see in my Parse Dashboard that they are being sent, but they are not getting delivered.

I am using a Notification Service Extension and set the Build Mode to Release there as well, but to no effect.

Changing the APN Authentication Key on Back4App back to Debug only allows me to receive push notifications again on my debug device.

I tried changing the APN Authentication Key (for either debug and production, since I cannot select both on Back4App) before force quitting the app, restarting it to get a new APN token saved to the ParseServer, and then sending the test notifications, also to no avail. I tried this for both my debug device and a TestFlight device, and it is always either my debug device (who gets the app straight from Xcode) or the TestFlight devices that are able to receive push notifications, never both.

I did not get around to trying it with APN Certificates for which I read that there are two distinct certificates for Production and Debug apps. While this option would be possible with Back4App, one big question remains - how do you implement push notifications both for debug and production apps in iOS with only one APN Authentication Key? And more specifically, how do you do that on Back4App?

Or are there any other ways around this issue besides the old APN Certificates? Since APN Authentication Keys are made out to be the future I'd rather implement it with that instead of the older APN Certificates.

Any help is appreciated, thanks in advance!

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

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

发布评论

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

评论(2

寻找一个思念的角度 2025-01-19 02:44:40

我找到了解决方法以及导致问题的原因:

使用 APN 身份验证密钥进行推送通知更容易实现且更方便,因为密钥不会过期,可以跨多个应用程序使用,并且不需要生成独立的开发和生产证书。

但是:APN 身份验证密钥只能用于开发推送通知或生产推送通知(这显然是 Apple 的意图)。

无论构建设置设置为“发布”还是“调试”,直接从 Xcode 获取任何构建的连接物理设备将始终将 APN 环境标志设置为开发 - 即使在构建之前手动将 APN 环境标志设置为生产也没有效果,它似乎在构建时重置并默认为开发。这意味着我的调试测试设备(物理连接到 Xcode)只能接收开发推送,这解释了我所描述的问题。

当归档构建并将其上传到 TestFlight 时,APN 环境标志会自动设置为生产;因此,所有 TestFlight 测试人员仅接收生产推送通知。

为了解决这个问题,我正在做的是将我的调试测试设备注册为 TestFlight 测试器,以便我可以从那里下载最新的版本并利用生产推送。我将这个特定的测试设备注册为其自己的组,以便我只能使用该设备来测试构建,而我不想立即将其推广到我的第二个(真正的)测试人员组中的所有其他 TestFlight 用户。

这是否意味着我始终需要存档任何新版本并通过 TestFlight 将其推送到我的测试设备以尝试新的东西?

不,仅适用于需要推送通知的事情。对于其他一切,我仍然可以直接从 Xcode 获得最新版本,因为所有本地存储的数据(例如登录的 Parse 用户或安装数据)都会保留在我的设备上,无论我是直接从 Xcode 安装新版本还是通过 TestFlight 自动更新安装新版本。

这样我就可以像往常一样工作,只需对任何与推送通知相关的功能执行额外的 TestFlight 步骤。

I found a workaround and what caused the issue:

Using APN Authentication Keys for push notifications is easier to implement and more convenient since keys don't expire, can be used across multiple apps and do not require the generation of independent development and production certificates.

But: An APN Authentication Key can only be used for EITHER development push notifications OR production push notifications (which is apparently intended by Apple).

No matter whether build settings are set to Release or Debug, a tethered physical device that gets any build straight from Xcode will always have the APN environment flag set to development - even manually setting the APN environment flag to production before building does not have an effect, it seems to be reset at build time and defaults to development. This means that my debug test device (physically connected to Xcode) can only receive development pushes, which explained my described issues.

When archiving a build and uploading it to TestFlight, the APN environment flag is automatically set to production; all TestFlight testers thus only receive production push notifications.

What I am doing to work around this is that I registered my debug test device as a TestFlight tester so that I can download my latest build from there and take advantage of production pushes. I registered this particular test device as its own group so that I can test builds only with that device that I do not want to immediately roll out to all other TestFlight users in my second (true) group of testers.

Does that mean I always need to archive any new builds and push it to my test device via TestFlight to try something new?

No, only for things that require push notifications. For everything else I still get the latest build straight from Xcode because all locally stored data (like a logged-in Parse User or Installation data) persists on my device, no matter whether I install a new version from Xcode directly or through TestFlight automated updates.

That way I can work as usual and only have to take the additional TestFlight step for any push notification-related features.

悲念泪 2025-01-19 02:44:40

奇怪的是,back4app 允许您上传“开发非生产”authKey。并且问题仍然存在。而且他们只允许你上传一个 AUTHKEY,所以这很令人困惑 AF

另外在我的 Android 应用程序上,我从 back4app 收到推送通知很好,但当应用程序在 Android 中终止时我没有收到它们。

另外,我将相同的身份验证密钥上传到 firebase,如果应用程序打开或关闭,我会从 ios 中的 firebase 收到推送通知。

back4app 故事的寓意是 hackeyAF

在此处输入图像描述

The odd thing, is that back4app allows you to upload a "dev non production" authKey. And problem still exist. And they only allow you to upload one AUTHKEY, so it's confusing AF

Also on my android app, i get push notifications from back4app fine, except i don't get them when the app is terminated in android.

Also my i uploaded the same exact authkey into firebase, and i get push notification fine from firebase in ios if the app is open or closed.

moral of the story back4app is hackeyAF

enter image description here

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