How to test Apple Push Notifications Feedback Service? - ios

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

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.

Related

Testing VoIP push messages - messages only arrive in-app

I have a very simple PHP test script that initially works, using the following server config:
$domain = "gateway.sandbox.push.apple.com";
$url = 'ssl://' . $domain . ':2195';
I'm receiving PushKit notifications every time I expect them including when the phone is locked. However testing it over and over while trying to implement the server side and convert it to HTTP/2, it just stops working reliably and only seems to trigger when I'm inside the application.
Inside the application: always works
Outside of the application including just backgrounded the app: works in the beginning, then stops working
It's very hard to get it to work if I don't know if even the most basic form of sending the message (through the PHP test script works). Also it worries me that my production application might suffer from the same kind of throttling if a user is sending too many messages (i.e. mom trying to call from the hospital 10x in a row).
I do always trigger CallKit in my PushKit code path every time so I think I'm good regarding to the changes in VoIP pushes in iOS 13.
What could be the cause of this different over time? How (if possible) can I prevent it? How can I detect it?
For that one person that upvoted my question but didn’t find a response:
Killing the app makes the OS think depriotitize it and it leads to the OS not forwarding the VoIP push anymore. To mitigate this problem as a developer you need to start the debugger without launching the app, so when you open the app from the push it can attach. Then kill the app only through the stop button in Xcode.
Testers need to be instructed about this problem. If you’re sure the code works for you and it stops working for the tester, they need to uninstall the app, restart the phone and install it again. If possible never kill the app manually. This sucks, I know it.

Twilio incoming calls not working for iOS

I'm really lost here.
At first, all calls between iOS-Android, Android-iOS, Android-Android and iOS-iOS, was working. Even so I still was getting errors like:
52143 - The push notification was rejected by APNs
52134 - Invalid APNs device token
But since was woking I ignored those errors.
Now, I had to change the client app to a new account - Apple and Google. And all start to fall apart.
I've already lost how many times that I deleted and create all the Apple Certificates and upload them to my Twilio account.
Right now, I have VoIP Apple Certificate working on production only from iOS to Android calls, but still getting those creepy erros.
And, if I run my APP and API all in LOCALHOST with the same Twilio Config and Apple Certificates, it all work beautiful except for those erros (52143,52134) that keep coming.
So... what could I be missing here?
This could be related:
https://github.com/twilio/voice-quickstart-objc/issues/33
https://github.com/twilio/voice-quickstart-swift/issues/34
https://github.com/twilio/voice-quickstart-objc/issues/115
https://github.com/twilio/voice-quickstart-swift/issues/142
https://community.clevertap.com/t/ios-error-apnsdevice-token-not-for-topic/545/3

iOS push token still valid after erasing an iPhone

So, I have an app in the store, I have downloaded it on my phone and obtained push token for that device. I tested silent push notification sending and indeed, it works, my device received it.
I wanted to check what is the time after push token will become invalid. First thing I did was simply uninstalled an app and was paying attention after which time I will start getting {"reason":"Unregistered","timestamp:1234567890} to my curl request which looks like this:
curl -d '{"aps":{"content-available":"1"}}' --cert "/Users/uerceg/Desktop/ProductionCertForMyAppsPush.pem":"password" -H "apns-topic:com.my.app" --http2 https://api.push.apple.com/3/device/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Once I have uninstalled an app from my device, it generally varies from case to case (I guess Feedback Service has some kind of tokens refresh logic I am not really aware of, nor I found some documentation about it, anyway), but it takes from 3-12 minutes to start receiving information that my app is uninstalled. Lovely.
After that, I wanted to test one more case - selecting Erase All Content and Settings and completely wiping out everything from my iPhone without restoring any backup afterwards.
Once I did that, app is removed as well. But curl request is always returning status 200. I waited for 5 days and after 5 days, it is still returning 200 as if app is installed, but my guess is that it shouldn't. Once erasing everything, I have newly installed my app, got new push token which I use to successfully send silent push notifications again.
Sure, if I have mechanism to identify that this particular device newly installed an app, I can update the token on the backend side not to send notification to that device anymore, but my question still remains: Why is Apple not invalidating the token in case where I have deleted my app by erasing and resetting my iPhone?
Maybe this is expected behaviour and my question doesn't make sense, but if it is expected behaviour, can you please point me to some documentation which is explaining this?
Thanks in advance.
Likely for the same reason that if you make a backup of your phone, and restore from backup, existing push keys still work. Invalidating the key on a device that is getting wiped would take out the potential that same key could be used from a backup.

swift 2 iOS 9 - Task running after app destruction: how do it?

I'm newbie in iOS App world so pardon me if my questions are simple and banals
I have this scenario:
my server side generates MQTT messages on a well known topic
my app can connect to the MQTT Topic and can receive messages
All works pretty good; what I would like to do now is the following (if possible)
When the user stops the app (by deleting it from the task manager) I'd like to have a kind of service able in being connected (or remaining connected) to the MQTT Topic; in this way also when the app is no more running I can receive MQTT messages
Basically I'd love to have something similar to Facebook messenger that is able in receiving messages also when the app is not running
NOTE: i can't use remote notification mechanism provide by Apple
Remote notifications would be perfect for this, shame that it's not an option for you.
There are a few other situations where apps can run periodically on the background, they are described here:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
BUT, from that page: "In most cases, the system does not relaunch apps after they are force quit by the user."
So in general an app will run in background only if the user exits it normally, not if he forces it to quit in the task manager.

Apple push notifications are no longer received

We released our phonegap application about a week back and everything was tested and working fine. Fast forward a few days and suddenly people start to report that they aren't receiving any push notifications. I go back to my test devices and fail to reproduce the error for a time but all of a sudden my device just stops receiving them.
I've gone on a debugging spree to try and identify the issue. I stepped through the server side code to ensure that the PushSharp code is being used correctly. I've checked the database to ensure that the user has an up-to-date device token and now I'm going though the steps listed here:
https://developer.apple.com/library/ios/technotes/tn2265/_index.html
When I enabled logging and sent a push notification a log was created with the appropriate timestamp so I know that SOMETHING happened. However, I'm still not receiving a pop-up on the interface and I can't see anything in the log that suggests it's gone awry.
Here is a pastebin of the log I extracted.
http://pastebin.com/KiCJEsDs
If this doesn't help is there anything else I can do to help identify the issue?

Resources