I implemented push notifications in my Android app using Firebase. I can retrieve the token and send messages using Firebase, but I want to know if there is a way to disconnect the notifications, with a timer, or something similar?
Asked
Active
Viewed 2,362 times
1
-
You can use `data` type of messages instead `notification` type and solve when show or don't push in client code. – Vladimir Parfenov Apr 19 '17 at 18:58
1 Answers
0
You could make use of the time_to_live
parameter:
This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks. For more information, see Setting the lifespan of a message.
Easy as the description says, it's like setting an expiration date. If the message is not yet delivered during that time, FCM discards it.
But if you intend to simply have the app to stop notifications altogether, you could:
- Simply stop sending towards the corresponding registration token.
- Implement a Push notification settings in your app, where if false (and if you're app is the one handling the push notification) have the method disabled.
- Lastly, call
deleteInstanceId()
. See my answer here.