Firebase: How to set default notification channel in Android app?

后端 未结 2 369
一生所求
一生所求 2020-12-02 20:26

How to set default notification channel for notification messages that come when an app is in the background? By default, these messages use \"Misc

相关标签:
2条回答
  • 2020-12-02 20:58

    As you can see here in the official docs, you need to add the following metadata element in your AndroidManifest.xml within the application component:

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_channel_id"
        android:value="@string/default_notification_channel_id"/>
    

    This default channel will be used when notification message has no specified channel, or if the channel provided has not yet been created by the app.

    0 讨论(0)
  • 2020-12-02 21:06

    you need to add Cordova config.xml

    <widget 
    ... 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    ...>
    
    
    
     <platform name="android">
        <config-file target="AndroidManifest.xml" parent="application" mode="merge">
          <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id"/>
        </config-file>
        <config-file target="res/values/strings.xml" parent="/*">
          <string name="default_notification_channel_id">urgent_alert</string>
        </config-file>
    </platform>
    
    0 讨论(0)
提交回复
热议问题