I've seen this discussed in a general way through various posts and message boards, but I wanted to ask this question more explicitly to ensure I'm understanding everything correctly.
My application is actually a Xamarin Forms application that interfaces with FCM through Azure Notification Hub, but my issue does seem to be related to FCM or at least how I've implemented the device specific code for notifications in Android.
Some Android devices, not all, that install our application will just stop receiving notifications at some point. In some cases it's immediate. The app is installed and the device is never able to receive notifications. In other cases, it could take as little as one day or as long as 3 weeks to stop receiving notifications, but it will stop.
If I try to send a message to an affected device directly through the Firebase console, nothing is received. If I try to use cURL I get a "not registered" error.
It's my understanding that OnNewToken() is supposed to be fired when the token changes. Generally, this is supposed to be on install, clearing data, or restoring a device, but I have learned that on occasion a token can just be updated, even while the app is running.
I'm trying to figure out how to best handle this.
If the device is running, I can expect OnNewToken() to be fired when the token is updated, right? If the app is not running when the token is updated, would I expect it to fire when the app starts again? Understanding that various devices can have settings for battery saving, background processes, etc, is there a time that I could epxect OnNewToken() to not be fired (even though it should have been)? To account for this, does it make sense to also call GetToken() in the OnCreate() method to compare what I think it should be to what it is? At least that way I can know I'm always using the most up-to-date token.
I haven't seen anything in the tutorials or documentation that seem to address this directly, so I hope I'm not over complicating it.
Any input or advice on this would be helpful, thanks.