Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test Apple Push Notifications Feedback Service?

What I did as a test is following:

  • I made example app where I enabled push notifications and implemented mechanism for handling them.

  • I was testing sending of silent push notifications to my app with curl and that works pretty well. I am testing that with:

    curl -v -d '{"aps":{"content-available":1}}' --cert "/Users/me/Desktop/mycert.pem":"" -H "apns-topic:com.domain.name" --http2 https://api.development.push.apple.com/3/device/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • As an answer from Apple, I am always seeing following:

    < HTTP/2.0 200

    < apns-id:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX

    Which is fine and as expected, according to Table 6-4 from the official docs: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html

  • Now I delete the app from my device and I retry the same request kinda hoping that I will start getting status code 410 and info that The device token is no longer active for the topic. How ever, that doesn't happen and I am always getting 200 status code like everything's fine and that the push token is still available.

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

like image 691
uerceg Avatar asked May 24 '16 09:05

uerceg


1 Answers

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.

like image 92
uerceg Avatar answered Oct 09 '22 08:10

uerceg