【发布时间】:2018-07-25 06:42:55
【问题描述】:
我已经实现了FCM。消息在Android N 和更低的设备中接收。
依赖
implementation "com.google.firebase:firebase-messaging:17.1.0"
我尝试从firebase 控制台发送消息。它显示在 Android N 中,但不在 Android O 中。
我已尝试从服务器发送数据通知。在Android O 中没有接到任何关于onMessageReceived() 的电话。
在显示通知时添加频道
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
// Since android Oreo notification channel is needed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelId,
"CRW notification channel",
NotificationManager.IMPORTANCE_HIGH)
notificationManager.createNotificationChannel(channel)
}
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build())
我已经在 Samsung S2 和 One plus 6 中检查了这一点。
除了设置通知渠道以显示通知外,我还需要为Android O 做任何额外的事情吗?
【问题讨论】:
-
让你检查一下这个Notification not showing in Oreo
-
是的,我在显示通知时添加了频道。
-
在设置中自动启动后尝试发送通知
-
过去 3 天我遇到了同样的问题,我的 FCM 消息是在 Android 7 上收到的,但不是在 8 上
-
这个@sunsun 有什么更新吗?你解决了吗?
标签: android firebase push-notification firebase-cloud-messaging