push-notification - FMC push notification android background
问题描述
I'm new in push notifications and I have an issue, when app receive a notification and app is open the class "FCMIntentService extends FirebaseMessagingService" execute correctly, but when app is closed or in background don't execute this class. Why? and Which class process the notification?
解决方案
Firebase 云消息传递有两个概念,一是“通知”,二是“数据”。
在前台通知被onMessageReceived()
正确发送到方法,但在后台的情况下,通知被发送到系统托盘参见图像。
解决方案:使用数据字段从服务器发送通知。
不要使用通知对象从服务器发送通知
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification":{ // Don't use the notification
"title":"Portugal vs. Denmark",
"body":"great match!"
}
}
}
使用数据字段从服务器发送通知,它将在后台和前台工作。
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data":{ // Use the data object to send the notification
"title":"Portugal vs. Denmark",
"body":"great match!"
}
}
}
推荐阅读
- php - 意外的循环结果
- asp.net-core - 找不到类型或命名空间 SigninManager<> 身份 3.1.1 Mediatr 8.0.0
- google-maps - 如何在仅包含地标文件夹的 KML/KMZ 文件中使用 NetworkLink refreshMode?
- python - 我无法在 anaconda python3.6 和 spyder 上成功运行 tensorflow-gpu
- ruby-on-rails - 如何在 PostgreSQL + Rails 上获得不同两列的计算值?
- reactjs - 如何根据父组件的更改重置组件的状态?
- asp.net - 使用 AngularJS 将数据从视图传递到 net-mvc 控制器
- javascript - Angular:ngOnInit 不加载我的函数?
- networking - 物理通信的通用“管道”概念的名称?
- php - Laravel 5.6 通知“没有发件人地址无法发送消息”