0
當我通過Firebase控制檯發送沒有在Android Oreo上指定的渠道的通知時,必須使用「其他」渠道或(如果從Android清單中提供了默認渠道)。所以我在我的應用程序中創建並提供默認頻道:Firebase消息傳遞:默認通知渠道不起作用
// 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的錯誤?
現在,它的工作,謝謝。我交付PR修復quicksta rt-android回購。 –
如何創建** notification_channel_id ** –