【发布时间】:2020-01-25 09:06:41
【问题描述】:
问题与Call onMessage method when the app is in background in flutter 相同,我正在关注该主题,但由于没有回应,我再次问这个问题。
我已将我的 Flutter 应用程序与 Firebase Messaging 连接,当我的应用程序位于 前台 时,我使用 Flutter Local Notifications Plugin 收到通知。但是当我的应用处于后台
时,我无法收到任何通知以下是我的代码:
// FIREBASE CONFIGURATION & HANDLING
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
debugPrint("onMessage: $message");
final notification = message['data']['notification'];
Map responseBody = convert.jsonDecode(notification);
_showNotification(
icon: responseBody['icon'],
title: responseBody['title'],
body: responseBody['body'],
);
setState(() {});
},
);
// DISPLAY NOTIFICATION - HEADS UP
Future<void> _showNotification({String icon, String title, String body}) async {
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'your channel id',
'your channel name',
'your channel description',
importance: Importance.Max,
priority: Priority.High,
ticker: 'ticker',
);
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
title,
body,
platformChannelSpecifics,
);
}
有人可以指导我如何在我的应用处于后台
时接收通知【问题讨论】:
-
是的。但不能解决我的问题。
标签: android firebase flutter push-notification firebase-cloud-messaging