I am developing a vehicle tracking application and am trying to implement functionality to notify users when a vehicle arrives at defined geofences.
I need to restrict notifications so that the user only receives them if they're actively tracking a vehicle in the app (they have to select which vehicle to track manually).
So far I've created a notification topic for each vehicle using Firebase's Topic Messaging. When the user presses the vehicle, the user is subscribed to that topic. When the user stops tracking the vehicle, they are unsubscribed from the topic.
This works very well. However, if the user force closes the app without leaving tracking mode using the interface, they continue to receive notifications even whilst the app is closed.
How can I unsubscribe the user from the vehicle topic if they force close the app, or change the implementation so that I can still provide the user with vehicle update notifications, but only when they've enabled tracking?