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 ** –