【发布时间】:2020-12-31 20:04:44
【问题描述】:
我是 Flutter 的新手,我只是想在我的 Flutter 应用程序中接收 Firebase 推送通知。当应用程序关闭并在后台接收推送通知。但是当应用程序打开时,推送通知正在接收,但它没有显示警报通知(如果它已打开,我想在我的应用程序中将推送通知标题和正文显示为警报)。这是我的代码。
_fcm.configure(
onMessage: (Map<String, dynamic> message) async {
showDialog(
context: context,
builder: (context) => AlertDialog(
content: ListTile(
title: Text(message['notification']['title']),
subtitle: Text(message['notification']['body']),
),
actions: <Widget>[
FlatButton(
child: Text('Ok'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
print("onMessage: $message");
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
},
);
有人可以帮我解决这个问题吗?
【问题讨论】:
标签: firebase flutter push-notification