How can we keep a Google Firebase push token alive? According to the Google documentation, the token expires in 30 days if the user uninstalls the app or loses their smartphone. However, we need the user to access the app to refresh the token and keep it alive on our server.
Is there a way to maintain the token without requiring the user to open the app? For example, could we send the token in the background? We've attempted this approach, but Android's privacy and security restrictions make it quite challenging.
Are there any alternative methods to achieve this?
From the Firebase documentation on stale and expired registration tokens:
Stale registration tokens are tokens associated with inactive devices that have not connected to FCM for over a month. As time passes, it becomes less and less likely for the device to ever connect to FCM again. Message sends and topic fanouts for these stale tokens are unlikely to ever be delivered.
When stale tokens reach 270 days of inactivity, FCM will consider them expired tokens. Once a token expires, FCM marks it as invalid and rejects sends to it. However, FCM issues a new token for the app instance in the rare case that the device connects again and the app is opened.
So an FCM token does not expire in 30 days. Rather an FCM token becomes stale if the device hasn't connected to the FCM server for 30 days, but FCM will still make messages available to the device with that token.
Only 270 days after the device connected to FCM for the last time does FCM consider the token expired. There is no way to refresh the token at that stage without the user actively using the app. Honestly: if the device hasn't connected to FCM servers after 270 days, then chances of it doing so later are miniscule.