簡體   English   中英

Firebase消息傳遞:默認通知通道不起作用

[英]Firebase messaging: default notification channel doesn't work

當我在沒有在Android Oreo上指定的頻道的情況下從Firebase控制台發送通知時,它必須使用“雜項”頻道或者如果從Android清單提供默認頻道。 所以我在我的應用中創建並提供默認頻道:

// Application onCreate
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    val manager = getSystemService(Context.NOTIFICATION_SERVICE) 
            as NotificationManager
    val channelId = getString(R.string.notification_channel_id)
    if(manager.getNotificationChannel(channelId)==null) {
        val channel = NotificationChannel(channelId,
                getString(R.string.notification_channel_name),
                NotificationManager.IMPORTANCE_DEFAULT)
        channel.description = 
                getString(R.string.notification_channel_description)
        manager.createNotificationChannel(channel)
    }
}

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

但它不起作用。 通知始終使用“雜項”頻道。 我在這里遺漏了什么或者它是Firebase的錯誤嗎?

道歉,顯然文檔沒有正確更新:(

清單中的正確元數據是:

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

注意android:name屬性值末尾的_id

將盡快更新文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM