Android 颤振-当应用程序位于后台时调用Firebase onMessage方法

Android 颤振-当应用程序位于后台时调用Firebase onMessage方法,android,firebase,flutter,push-notification,firebase-cloud-messaging,Android,Firebase,Flutter,Push Notification,Firebase Cloud Messaging,这个问题和这里的问题是一样的,我是按照这个思路来的,但是由于没有回应,我再次问这个问题 我已将我的颤振应用程序连接到,当我的应用程序处于前台时,我将使用收到通知。但当我的应用程序处于后台时,我无法收到任何通知 以下是我的代码: // FIREBASE CONFIGURATION & HANDLING _firebaseMessaging.configure( onMessage: (Map<String, dynamic> message) async { deb

这个问题和这里的问题是一样的,我是按照这个思路来的,但是由于没有回应,我再次问这个问题

我已将我的颤振应用程序连接到,当我的应用程序处于前台时,我将使用收到通知。但当我的应用程序处于后台时,我无法收到任何通知

以下是我的代码:

// 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,
  );
}
//FIREBASE配置和处理
_firebaseMessaging.configure(
onMessage:(映射消息)异步{
debugPrint(“onMessage:$message”);
最终通知=消息['data']['notification'];
Map responseBody=convert.jsonDecode(通知);
_展示通知(
图标:responseBody['icon'],
标题:ResponseBy['title'],
body:responseBody['body'],
);
setState((){});
},
);
//显示通知-平视
Future_showNotification({字符串图标、字符串标题、字符串正文})异步{
var androidPlatformChannelSpecifics=AndroidNotificationDetails(
'您的频道id',
'您的频道名称',
“您的频道描述”,
重要性:重要性,马克斯,
优先:优先,高,
股票代码:“股票代码”,
);
var iOSPlatformChannelSpecifics=ioNotificationDetails();
var platformChannelSpecifics=通知详细信息(
androidPlatformChannelSpecifics、iOSPlatformChannelSpecifics);
等待本地通知。显示(
0,
标题
身体,
平台通道细节,
);
}

有人能告诉我当我的应用程序处于后台时如何接收通知吗

问题在于curl调用的格式。按照给出的说明

更改为:

{
  "data": {
    "notification": {
        "title": "Notification Title",
        "body": "Notification Body",
    },
        "click_action": "FLUTTER_NOTIFICATION_CLICK"
  },
  "to": "YOUR_DEVICE_TOKEN"
}
为此:

{
  "data": {
    "click_action": "FLUTTER_NOTIFICATION_CLICK",
    "id": "1",
    "status": "done",
  },
  "notification": {
    "body": "Notification Body",
    "title": "Notification Title"
  },
  "priority": "high",
  "to": "YOUR_DEVICE_TOKEN"
}

你检查过这个了吗?是的。但这并不能解决我的问题。