Use Firebase Theme Messages with Android Notification Channels

I have an application with various types of notifications that it can receive (e.g. News and Podcast ). It currently has two simple switches in which the user can enable and disable these different types of notifications. It works by simply signing up and unsubscribing from the appropriate Firebase theme for this type. A clear advantage is that the device receives only the notification that the user wants, and should not filter them locally => battery and effective data.

The problem is that I want to combine it with the new Android notification channels. Do I correctly assume that the only way is to simply subscribe to all topics in Firebase and manually disconnect the user from unwanted ones in the Android settings?

Is there a better way that saves battery life (without getting all notifications)?

+5
source share
1 answer

The Notification Channel (a feature needed only for Android O - presumably from now on) is (like) a parameter that you (usually) use to sort / manage notifications that you create locally. -

Android O introduces notification channels to provide a single system that helps users manage notifications.

This does not necessarily turn off the receipt of notifications that you do not want to receive, but (AFAIK) notifications created without the Notification Channel will not be displayed / displayed in Android O (not received! = Not displayed). those. Your device may still receive notifications, but just does not appear.

For notifications sent by topic, if the signed token is signed, it is expected that the client will process it accordingly .

For all that you have already implemented (if I understand your message correctly - subscribe and unsubscribe to topics based on some kind of switch), this is the easiest way you could get it.

If you want to completely disable alerts completely, you can call deleteInstanceId() . See my answers here and for more information.

+4
source

Source: https://habr.com/ru/post/1270387/


All Articles