I'm using Firebase's FCM for push notifications for an app. There is a need to subscribe to certain topics from the moment the user starts the app.
So far I've handled "topics" and various metrics on our own server, but as we're moving logic parts to their appropriate place to lessen the load on our server, this needs to be moved to Firebase itself.
And we want to handle things a bit differently. Users will be able to subscribe and unsubscribe to/from certain notification groups, however FCM's documentation does not mention which is the time, which callback is the proper place to handle this.
The flow would be the following:
- User installs app
- User launches app
- App updates cached data (information that changes in larger intervals, e.g. every 3-6 months)
- App pulls synced data, including topics list, from Google account
- App registers device for push notifications
- App subscribes user to "all" topic (all users that want to receive generic notifications are registered here. Unsubscribing is only possible if the user unchecks the "send me notifications" option in settings)
- App subscribes to the topics synced in step 4
What isn't clear is WHERE to place steps 6 and 7. Do I put it into my implementation of FirebaseInstanceIdService, into OnTokenRefresh on Android, and in Messaging.SharedInstance.Connect or InstanceId.Notifications.ObserveTokenRefresh on iOS? Do I need to re-register to topics when an FCM token change happens?
The app is written in Xamarin, so we're using FCM for both iOS and Android.