应用程序收到我在后台或关闭模式下发送的所有通知,但我还想在用户使用应用程序时显示应用程序打开时的通知。
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
FlutterRingtonePlayer.playNotification();
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
// TODO optional
},
如果你想在系统托盘中显示通知,就像应用程序在后台时一样,你可以使用包。扑腾_本地通知.
这样一来,当您通过 onMessage
你可以使用这样的东西。
AndroidNotificationDetails notificationAndroidSpecifics =
AndroidNotificationDetails(
groupChannelId, groupChannelName, groupChannelDescription,
importance: Importance.Max,
priority: Priority.High,
groupKey: groupKey);
NotificationDetails notificationPlatformSpecifics =
NotificationDetails(notificationAndroidSpecifics, null);
await flutterLocalNotificationsPlugin.show(
1,
'Jeff Chang',
'Please join us to celebrate the...',
notificationPlatformSpecifics);
检查他们的文档,以获得更多的例子!