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
Related
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.
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.
I am developing a sample app for iPhone to receive GCM messages. It registers successfully, getting a registration token. Using this token I submit a message to GCM server with it replying success. This has no visible effect on the phone or in the app.
This is true if phone is on, access code entered, both with app running or not running.
What I already checked/tried:
SenderID, registration token, server auth key are correct. Also tried to reinstall app to get new registration token, problem persists.
Put trace logs into all callback functions, the ones about registration are called how I expect them to be called, the ones about receiving messages are silent.
Tried it on wifi and GSM network too, same.
Attempted to find a solution here on stackoverflow.
I couldn't check but I am quite confident that there are no ports blocked on wifi.
What can possibly be wrong? Any ideas what else I am to check?
In order for us to send users iOS notifications the following flow occurs: a user installs our app, registers with APNS, and sends the registration token to our server to be used later to send notifications.
The above process is repeated for every device on which the user installs our app; we'd like them to get notifications on all their devices.
In addition to this, the process is repeated when a user uninstalls our app and reinstalls on the same device.
Every time the process repeats we get a new, distinct registration token. This is all well and good however, we noticed that only recently when our app is uninstalled, the device token remains valid after it is reinstalled and a new token is generated. It is our understanding that a single unique token can exist for a device.
Apple's documentation seems to suggest this as well (https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW12)
The form of this phase of token trust ensures that only APNs generates the token which it will later honor, and it can assure itself that a token handed to it by a device is the same token that it previously provisioned for that particular device—and only for that device.
When a new token is generated after reinstall and sent to our backend, we've got two device tokens that point to the same device and as a result we send multiple notifications to that device. Are we misunderstanding the documentation? If so, what's the typical way of dealing with the reinstall scenario?
Thanks!
We just did a test here. On our iOS 8.4.1 test device after reinstalling our app we've received the same token, whereas on iOS 9.1 we always receive a new token after re-installing. This wouldn't be a problem if APNS invalidates the older device tokens, but as far as I can tell it does not. The result is that we're sending duplicate notifications to our users to the same device. Maybe it takes some time to invalidate older token?
We decided to do a server-side fix for this and remove duplicate tokens for one user from our database. Not a good and permanent solution, but a short-term fix for us since our users use the app usually on one device only.
Yes, I am seeing a single device with the same app (my app), which has been issued different APNS over its short life, many of which are still capable of still receiving a push notification (from production APNS server).
The easy fix would be to just have our backend APNS sending service to only honor the last APNS token received. This is doable, assuming there is another primary key that is unique to every iOS device. Well, since UUID is no longer available, then we have to rely on the Apple Vendor ID. That problem with the Apple Vendor ID is that value can also change over time, so be sure to account for that.
We currently only send push notifications to devices which have our unique member/user ID. This is known to our app, once a user has signed into our app. So, we could use our member/user ID, but if a member/user has multiple devices, that means if we use the last APNS token value as the one that wins, than the same member could NOT have multiple iOS devices receiving push notifications (think iPad and iPhone, pretty common these days).
So, with that being said, when upper-management wants to send push notifications to devices in which no unique member/user has actually signed into, there is a risk of the streams getting crossed.
We have the same problem that we found 2 valid device tokens for 1 device.
However, when we tried to verify "uninstalling and reinstalling would generate a new device token, and the former device token is still valid", we got the opposite result.
Namely, the new device token was generated, but the former device toke became invalid.
I verified this on 3/9/2016 and 3/10/2016.
Not sure if Apple has fixed this bug partially:
a) when the app is uninstalled and reinstalled from now on, the old deviceToken become invalid. (no new issues)
b) currently valid device tokens will continue to be valid. (old issues can't be fixed, the device will still receive multi notificatioins from each valid device token)
Looks like we'll have to use "identifierForVendor" to distinguish a unique device: Cleaning our registration table (and keep the latest deviceToken only) if we see 2 deviceTokens share the same identifierForVendor.
"Every time the process repeats we get a new, distinct registration token".
Are you sure about that? 100% sure?
In my experience if you uninstall the app, then re-install it then 99.99% of the time you will get the same device token. If you are getting a new unique device token every single time you uninstall and then reinstall the app then that is something I've never seen in multiple years and multiple apps. Hence maybe something strange is going on.
There are instances when a new device token will get generated but they are rare, are you sure you are not doing something else between uninstallation/re-installation?
P.S. there is a different device token for production builds and release builds, eliminate this factor from your observations - i.e. make sure you're not doing something like installing a prod build, then uninstalling it and re-installing a dev build or vice versa. Even if you are doing this the total number of unique dev tokens would still only be two (though only one is valid per environment).
Hi i am implementing IOS MDM using JavaPNS. Steps performed up to now.
1)I installed xxx.mobileconfig file on IOS Device.
2)I am using JavaPNS for sending notifications.
3)I got PushMagic token from my IOS Device.I got 200 Response.
4)I am using https:// for checkin url. I am using IPCU for generating mobileconfig files.
5)My intension is install some custom payload like disable the camera,disable the youtube ..etc.
6)I am using Restriction payload for that .I am sending the push notification but the IOS Device cannot responding to my server...
The following issue seems to be my issue so can any one guide me.
http://code.google.com/p/javapns/issues/detail?id=103
Any advice would be appreciated.
Try the following
Download and install iPhone Configuration Utility.
Connect your device and open console tab
Send a command from server to the device and see logs (see image below)
If you can see traces of MDM in the logs such as starting, polling etc, that means the device has received the APNS message and is trying to connect to the MDM server for commands.
If in the console you find some error, you need to further investigate.
If you don't see any traces of MDM in the logs, then probably there's some issue - either with the server (invalid push token etc) or with the device's internet connection.
Please post the results and ask for more details if required.