Apple push notification tokens - ios

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.

Related

Firebase push notifications iOS: getting NotRegistered. Why?

I implemented firebase push notifications in React native on Android side: all things are working fine.
In the iOS side I'm getting NotRegistered, why?
That's the response:
data:NOTIFCATION {
deviceToken: 'diTk7DNPS9KsRTPSFlpSoU:APA91bEaNxB9W0g6m8487W37qTgUYmqGA2GfN1tPbwI1q60WAsHFrCdhbYzEZO-q5lfY1s3epNsSKhHpxO-OLYMGED3ZeYi_f7DHUrOpxMgC0QE7KJFslZwk3-CKnqbfkClu3tzUL6_X',
title: 'Extended Session',
message: 'Please extend Your parking Session expire soon'
}
{"multicast_id":8523782171183643556,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]} Something has gone wrong!
As mentioned in documentation if you correctly registered the iOS token, there are some possible causes:
An existing registration token may cease to be valid in a number of scenarios, including:
If the client app unregisters with FCM.
If the client app is automatically unregistered, which can happen if
the user uninstalls the application. For example, on iOS, if the APNs
Feedback Service reported the APNs token as invalid.
If the registration token expires (for example, Google might decide
to refresh registration tokens, or the APNs token has expired for iOS
devices).
If the client app is updated but the new version is not configured to
receive messages.
For all these cases, remove this registration token from the app server and stop using it to send messages.

Upload iOS device token for Push Notification

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

Will APNS token still work after getting a FCM 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

Sending device unique token to the push notifications provider

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.

Apple Remote Notifications - Handle Token change

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.

Resources