image.png
三、推送接受消息回调⽅法实现
3.1 介绍⼀下firebase_messaging,推送⼏个回调⽅法触发时机
Ap
p在
App在后台时App进程被⼲掉时
Notific ation on Androi d on
Me
ssa
ge
Notification被传递到系统,当⽤户点击推送通知
时,如果设置了click_action:
FLUTTER_NOTIFICATION_CLICK, 则onResume
被触发
Notification被传递到系统,当⽤户点击推送通知
时,如果设置了click_action:
FLUTTER_NOTIFICATION_CLICK, 则onLaunch
被触发。
Notific ation on iOS on
Me
ssa
ge
Notification被传递到系统,当⽤户点击推送通知
时, 则onResume被触发
Notification被传递到系统,当⽤户点击推送通知
时,则onLaunch被触发
安卓intent用法
Data Msg on Androi d on
Me
ssa
ge
onMessage插件不⽀持,消息丢失
Data Msg on iOS on
Me
ssa
ge
消息由FCM存储,并在应⽤回到前台时通过
onMessage触发
消息由FCM存储,并在应⽤回到前台时通过
onMessage触发
因为Firebase 推送消息有两种⼀种是Notification ,⼀种是Data message消息,以上表格是两种消息分别在Android、iOS平台应⽤状态不同时的回调接⼝情况
Flutter 处理代码如下: