我是Flutter的新手,目前正在尝试将firebase推送通知发送到我的Flutter应用。当应用程序关闭和在后台时,可以接收到推送通知。但是当应用程序打开时,虽然可以接收推送通知,但它没有显示警报通知(如果应用程序已打开,我希望以警报的形式在我的应用程序中显示推送通知标题和正文内容)。以下是我的代码。
_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");
},
);
能否有人帮我解决这个问题?