且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何测试 Apple 推送通知反馈服务?

更新时间:2022-11-03 13:46:11

好的,根据我的发现,Apple 的 Instant Feedback 服务运行良好,并且能够检测到卸载相当快.如何使用沙盒服务正确测试这些东西有一个小技巧.

如果您制作了一个应用程序并在您的设备上进行本地测试,并且您的应用程序是手机上唯一通过该配置文件(供应商)安装的应用程序,那么我在会遇到我的问题.出于某种原因,即使您卸载了该应用(这是手机上唯一从您的配置文件中安装的应用),Apple 也会始终响应 200.

需要做的事情如下:安装正在测试的应用程序后,使用另一个包 ID 创建一个新的虚拟应用程序,但它也来自您的配置文件,在其中启用推送通知并安装它在您的设备上.所以现在,您制作了两个应用程序 - 一个用于开发和测试 Instant Feedback 服务,另一个类似僵尸"应用程序,它只是坐在那里什么也不做.>

在此之后,卸载您的测试应用程序,尝试发送静默推送通知,Apple 将按预期以 状态代码 410 响应.

虚拟方式,但出于某种原因,测试时应该是这样.生产中的行为应符合预期,无需在 iOS 设备上安装来自同一供应商的虚拟(或任何其他)应用.

What I did as a test is following:

1 - 1.5 hours after deletion, I am still getting 200 as an answer.

Do you maybe know how often does Apple refresh push tokens list and when I can expect to eventually start getting 410? And also - is 410 status (and Instant Feedback in general) testable at all while testing the app outside of production environment?

Thanks in advance for any kind of answer.

Cheers

Okay, so from what I have discovered, seems that Instant Feedback service from Apple is working just fine and is able to detect uninstall pretty fast. There was a small trick in how to test these things properly with sandbox service.

If you make an app which you are testing locally on your device and your app is the only one installed on your phone from that provisioning profile (vendor), stuff which I faced as an issue in my question will be encountered. For some reason, even if you uninstall the app (which was the only one on the phone installed from your provisioning profile), Apple is always responding with 200.

What needs to be done is following: After you install your app which you are testing, create a new dummy app with another bundle ID, but which also coming from your provisioning profile, enable push notifications in it as well and install it on your device. So now, you have two apps that you made - one which you are developing and testing the Instant Feedback service with and another one which kinda "zombie" app which just sits in there and does nothing.

After this, uninstall your test app, try to send silent push notification and Apple will respond with status code 410 as expected.

Dummy way, but for some reason that's how it should be while testing. Behaviour in production should be as expected and w/o any need to have a dummy (or any other) app from same vendor installed on iOS device.