I have a game running in Appstore which connects to one of our development server and now as it is live, I am not able to send push notifications. I need to move it from develpoment server to production server (Urban airship) and it gives me new Api/secret keys. If I update these keys and update my application, will it show alert popup/register to all existing device again to new server? We have around 75k users and I can't afford to loose them! Any idea whats the safest way to play!!
Got it!
The way iOS works, you don't have to worry about the Devices Tokens not registering. Devices will have two Device Tokens per install of an app, a Production Device Token and a Development Device Token, so you should see the new Production Device Token get registered to the app as soon as the user updates and opens the app the next time around. And then you'll be set!
Related
I am asking about two situations:
1) After we do a regular update from the App Store
2) After we simulate an update, by downloading a current version from a Store and installing & running a new version from within Xcode,
does push notification token changes? If changes, how often eg. each time, or from time to time?
I ask this, because I was doing some testing, where I want to preserve Documents folder after an update. So this can be easily done like I described above, by downloading the app from the Store, and running a new version from within Xcode. But, I noticed that push notifications stopped to work. Then I repeated this few times (uninstall the app, install it from the store, then run the upgraded version from Xcode) and every time push notifications worked.
I wonder if this was due to push notification token change?
See Apple Docs:
Never cache device tokens; always get them from the system when you
need them. Although device tokens are unique to an app and device,
they can change over time. The device token can change at any time but
is guaranteed to be different when the user restores their device from
a backup, when the user installs your app on a new device, and when
the user reinstalls the operating system. Fetching the token from the
system ensures that you always have the current token needed to
communicate with APNs. In addition, if the token has not changed,
fetching it is fast and does not incur any significant overhead.
So based on Apple docs there are at least 3 places that it changes:
Restore from backup
installs on new device
reinstalling the OS
So a typical update doesn't change them. I don't ever remembering myself having to agree to receive after an update...
IMPORTANT NOTE:
If a user logs out of the app and a new user logs into the same device, then the token would remain the same. Why? Because there's no class or messaging system exposed to developers to let the OS know it has to deregister a token from device.
Hence you must unregister that token from that user/account ie you have to make some sort of network call you to your platform, otherwise new user would be receiving push notifications that belong to previous user.
As far as I know,
1) Regular update from the App Store - APNS token doesn't change.
2) It's a bit tricky. And I believe token changes. First I want to let you know the appstore version uses APNS production certificate and the build run from with xcode uses development one. It will generate different token. And if you still send push notification to the apple push production server, you won't get them on your xcode version. You need to send them to the apple push sandbox server.
So I'm running into a peculiar problem that I have not been able to find much information on. Looking for any input or experience at all.
I have recorded the deviceToken of an existing app install using Urban Airship. Then deleting the app and reinstalling, I recorded the new device token as well. These tokens are different. From the UA test panel, I am able to send a test push to both of these tokens and the device receives 2 pushes, one for each token, even though the first token has since been uninstalled. But, in UA device lookup, both tokens are marked as active.
This was only caught after getting our push server running which triggers a push once every morning at most, based on a hosted file that determines the push contents and if one should happen. My development device is now getting up to 8 pushes at once from the server.
There are ways to unsubscribe or unregister for push notifications with Apple, UA, and the server, but I'm wondering on the best practices for this. There is no way to get the uninstall event either which would be the only time to unsubscribe. Is the best solution just to wait for UA to determine a token is inactive? I have found this list here for reasons a token could be inactive: http://docs.urbanairship.com/reference/troubleshooting/ios-push.html#inactive-device-token
But none seem to apply here, especially because some of these device tokens are nearly a month old and still sending to my test device. The app uses an Enterprise profile so this is happening in a production environment.
Are you getting the same channel every time? Usually reinstalls will generate the same channel which is tied to a single device token. Then when apple generates a new token it will update the channel's token. You are probably better off contacting support directly. They will be able to help gather all the device info they need and look up registration and push records to figure out whats going on.
I’m providing this question and answer because I’ve not seen the problem I ran into with the fairly common ‘APNS not working problem’ and perhaps my experience could help others.
One of my apps that I have in the store uses push notifications. Version 1 of the app was working just fine. No problems.
I created version 1.1, tested it on the sandbox APNS (worked fine) and submitted it. Sometime after 1.1 was approved I noticed push notifications weren’t working. My device was not receiving any push notifications, nor was any other user. That naturally led me to believe I’d screwed up something with the certificates or something like that when I created v 1.1. I checked all the normal things - sandbox vs production, certificates, provisioning profiles, etc. No dice.
--My server setup
I’m doing the interaction with the APNS servers myself and whenever I send an APNS message to Apple I got a positive response. My server code opens a connection to the APNS gateway, sends an APNS message for every device that needs one, then closes the connection.
(this next bit is key to the problem)
In the user record in my DB, I keep track if the user installed the dev version of the app or the production version of the app. I keep this as a flag in the user record. I do this for ease of use.
For simplicity sake, I have one script that processes the development users and sends their APNS messages to the sandbox server and separate code that sends the production user’s APNS messages to the production APNS gateway.
All of that was working fine. I’ll save you all the recertification steps and other grief that I did.
As far as I could tell everything was working fine and everything was set up correctly. So I followed the advice of Ms. Rand: “Contradictions do not exist. Whenever you think that you are facing a contradiction, check your premises. You will find that one of them is wrong.”
After too many hours trying to figure out what was going on I finally determined the problem.
I had turned a development user (my wife’s iPhone) into a production user as I thought she had downloaded the production release of the app
For this user, my server was using the deviceID generated from the development app and sending that to the production APNS server
Whenever I would send that device ID to the production server as one of the APNS messages, even though I would get a positive response from the servers, none of the APNS messages to any other devices would work.
Once I flipped her user record back to be a development device, everything began working again.
I verified multiple times that this was the problem.
So, it appears that using a deviceID that’s intended for sandbox APNS interaction and sending it to the production APNS really screws things up.
Hope this helps somebody in the future.
I was testing my iOS app I found one interesting thing that even my phone is in airplane mode and I have also switched off WIFI, my app is able to receive the the Device Token after registering for push notification.
I have also tried even after removing app and its associated certificate from the iPhone.
but got same results.
How is it possible, any idea ?
thanks in advance.
This is from the APNS programming guide :
By requesting the device token and passing it to the provider every
time your application launches, you help to ensure that the provider
has the current token for the device. If a user restores a backup to a
device or computer other than the one that the backup was created for
(for example, the user migrates data to a new device or computer), he
or she must launch the application at least once for it to receive
notifications again. If the user restores backup data to a new device
or computer, or reinstalls the operating system, the device token
changes. Moreover, never cache a device token and give that to your
provider; always get the token from the system whenever you need it.
If your application has previously registered, calling registerForRemoteNotificationTypes: results in the operating system
passing the device token to the delegate immediately without incurring
additional overhead.
It implies that if your application is already registered for push notifications, calling the registerForRemoteNotificationTypes doesn't access the APNS server.
The fact that you uninstalled the app doesn't unregister it from APNS. You can prove that to yourself by calling the feedback service immediately after uninstalling the app. You wouldn't get the device token from the feedback service in this case, because the APN service doesn't know you uninstalled the app. Only if you send notifications to the device after uninstalling the app, the APN service will know the app was uninstalled.
when I connect to the feedback service, it can successfully connected, but i get nothing from the feedback service.
i have uninstall the app from my device, and push again, and then connect to feedback service, but i still get nothing, even the next day.
Any idea?
If you remove your app from your device or computer and then send a
push notification to it, you would expect to have the device token
rejected, and the invalidated device token should appear on the
feedback service. However, if this was the last push-enabled app on
the device or computer, it will not show up in the feedback service.
This is because deleting the last app tears down the persistent
connection to the push service before the notice of the deletion can
be sent.
You can work around this by leaving at least one push-enabled app on
the device or computer in order to keep the persistent connection up.
To keep the persistent connection to the production environment up,
just install any free push-enabled app from the App Store and you
should then be able to delete your app and see it appear in the
feedback service.
Recall that each push environment has its own persistent connection.
So to keep the persistent connection to the sandbox environment up,
install another development push-enabled app.
source: Apple Documentation
So just install any push-enabled app from the app-store after uninstalling your own app and your devicetoken should be triggered by the Feedback-Service.
Pay attention to the certificate & environment you are using (sandbox/production). Also keep in mind that the Feedback-Service only list failed delivery-attempts from your last push.