简体   繁体   中英

How to set channel when sending a notification from Firebase to an Android device?

After setting the Notification Channels on an Android app, and having most notifications being sent from a backend system, how do you set a notification's channel from the backend?

If the notification payload being sent from the backend is:

  "message": {
    "topic" : "foo-bar",
    "notification": {
      "body": "This is a Firebase Cloud Messaging Topic Message!",
      "title": "FCM Message"
    }
  }

then where should the channel be added ?

I believe you are looking for android_channel_id :

The notification's channel id (new in Android O).

The app must create a channel with this ID before any notification with this key is received.

If you don't send this key in the request, or if the channel id provided has not yet been created by your app, FCM uses the channel id specified in your app manifest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM