Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is FCM token refreshed on app update?

Tags:

I am using FCM in my android app for push notifications. I have the below class to get the fcm token.

public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {     @Override     public void onTokenRefresh() {         String refreshedToken = FirebaseInstanceId.getInstance().getToken();     } } 

This is called correctly when my app is installed and I am able to get the token. However I am not sure if my app is updated(from play store) then this method will be called or not. The documentation just says that the method will be called whenever the token changes. But updating the app might not change the token.

like image 889
anurag bhowmick Avatar asked Dec 26 '16 10:12

anurag bhowmick


People also ask

Does FCM token change on app update?

yes it does not change token upon updating.

Do FCM tokens expire?

Ensuring registration token freshness To cover all cases, you should adopt a threshold for when you consider tokens stale; our recommendation is two months. Any token older than two months is likely to be an inactive device; an active device would have otherwise refreshed its token.

Does FCM token change iOS?

Its working fine in Android and IOS. But in iOS (only app killed/terimtaed stage) after updating the location when the silent push notification receive, the device fcm token automatically changed.

How does FCM token work?

Firebase Cloud Messaging (FCM) is a messaging solution that lets you reliably send messages at no cost to both Android & iOS devices. Using FCM, you can send data payloads (via a message) to a device for a specific application. Each message can transfer a payload of up to 4KB to a client.


1 Answers

As pointed out in the post by @Dharmitabhatt in the comments section, a registration token is not refereshed when an app is updated.

Whenever a token is refreshed in Android, it should call the onTokenRefresh() method:

Called when the system determines that the tokens need to be refreshed. The application should call getToken() and send the tokens to all application servers.

This will not be called very frequently, it is needed for key rotation and to handle Instance ID changes due to:

  • App deletes Instance ID
  • App is restored on a new device
  • User uninstalls/reinstall the app
  • User clears app data

The system will throttle the refresh event across all devices to avoid overloading application servers with token updates.

So you are right to say that updating the app doesn't necessarily refresh the token.

like image 164
AL. Avatar answered Oct 21 '22 03:10

AL.