I would like to know how to manage the iOS device token App & Server Side.
First, I registered my app to receive remote notification. So, I got the device Token.
My questions are :
App Side
When Should I send the token to the server ?
If Many times, how often ? Each log Request ?
I should send the token to the server directly from this method application:didRegisterForRemoteNotificationsWithDeviceToken: or store it, and send it in an other method ?
Server Side
Once I have the token on the server, how can I know if the token is still valid ? Or that I should delete it cause the device token is not available anymore.
App side
It's better to upload it in every api request to track the user devices as he may login in his account from multiple devices , so you should have array of device tokens in server , or only one token if you want to track the last device the user is active with so , store token from didRegisterForRemoteNotificationsWithDeviceToken say in user defaults and upload it for every api request
Server side
The token is still valid if the php script used to send it returns success operation but if not that may also mean .pem file is incorrect
Related
my app's apple push notification certificate is expired. Before expiration server used curl.. Now I renewed it and used JWT for sending notification on my server..
Now, I'm trying to send push notifications to users. Can I use the device token from certificate back then or do I have to change the code from app to get new token? Thanks
As explained here in 'Figure 6-6, Managing the device token', if the device token needs no refresh, you can use it with your new backend implementation without any changes needed on client-side.
No matter what, you need to check and send the device token to your server on each app launch to ensure that you have the newest device token.
Our company send push notification from the server side with the APNS token obtained from device, and we are currently migrating over FCM.
My question is once the user upgrades to the new app using the FCM token, will the old APNS token still work?
I am asking because the current design of the app has a disconnect and it could wait up to an hour before the device updates the server with the new FCM token. During that time, the server will continue to send push notifications with the old APNS token, and we want to make sure user is still able to receive them.
If anyone can give any insight on that, that will be great! Thanks!
Yes , it will as long as you use the correct device token and uploaded the .pem file but make sure to separate the usual token from FCM token , regarding firebase you should upload .p12 development & dis files , there is no big deal behind firebase it also sends the push content to apns
My push notifications provider wants me to send a device-unique token to the server, which is not possible, as I figured out after hours of searching (neither with keychain nor identifierForVendor etc).
So atm server stores tons of inactive tokens (after app is reinstalled, token is being refreshed). What is the workaround in this situation?
If you are talking about the notification APN token to the server, the server can cull them when they attempt to use them.
The Apple Push Notification server will let them know the token is invalid.
I currently have a functional iOS application (with react) and an app server using nodejs. So far, I am able to register with Firebase Messaging and console log my registration token through the AppDelegate.m file. And from my server, I can send my app a notification on a certain device with a POST method. However, in order to do that, I have to copy my registration token from the consolelog and paste it in the post request. Which is pointless because the token can change at any time.
I am still fairly new to this and I cannot find any examples of people sending their registration token to their app server. In all of the documentation it is always just a comment like "//If necessary send the token to your app server" with no explanation on how to go about it.
I just want to send the registration token to my server every time it refreshes so I can save it, and then send downstream messages to certain devices using their latest tokens. How do I get the Firebase token from my Obj-C AppDelegate file to my javascript server side? Can anyone help me out? Or show me an example?
You are on the right track, your app server will need an endpoint (say /register) that will let you make an http request posting your token to your app server.
I need to use Notifications via APNS in my iPhone App.
But as I read specification, I see the Token can be changed on APNS side and I have to update token on Provider side to receive notifications right.
But what will happen when Provider creates Notification and will pass it to APNS and in this time the token will be already changed?
Will I receive a Notification with old token? Will provider be notified that token expired?
Should I solve it so, that after registering I will update my Provider with info "YOU CAN SEND NOTIFICATIONS" and make a NSTimer job to update this state while app is running?
According to this:
http://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW2
Thanks
If your app registers for notifications at launch, and implements the methods specified in the documentation, it will be sure to get the correct token.
If your app keeps track of what the token used to be, it can send an update to the provider as needed (or just every time it gets a token whether it has changed or not).
If the token has changed, and the provider tries to push using the old token, the provider will be notified by the push notification server that the token is not valid.