【发布时间】:2017-12-03 11:43:57
【问题描述】:
我正在从我的服务器发送数据有效负载通知。这是一个例子:
url= "https://fcm.googleapis.com/fcm/send"
{
"to" : "userToken",
"data" : {
//some json here
}
}
以这种方式,即使应用程序没有运行,我也可以在所有预 Android O 设备中成功地向用户发送消息。 但在 Android O 设备上,应用未启动时不会调用 onMessageReceived...
在 O 中有一些新规则吗?如何解决?谢谢!
更新
这个问题不是关于通知,而是关于 firebase 消息服务!
反正Android O的chanels也实现了:
val CHANEL_ID = "MY_CHANEL_ID"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(CHANEL_ID, "Channel human readable title", NotificationManager.IMPORTANCE_HIGH)
(getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).createNotificationChannel(channel)
}
【问题讨论】:
-
你在 manifest 中声明了服务类吗??
-
当然。其他(前 O)设备成功接收到此消息
-
你找到解决办法了吗?
-
@dakshbhatt21 看起来问题出在我的一加氢测试版中。当我放下它并彻底刷新手机时 - 它工作正常。
-
@AndriyAntonov 好的,我也会尝试并发布更新
标签: android push-notification firebase-cloud-messaging android-8.0-oreo