FCM推送通知onResume不起作用

时间:2020-03-16 13:53:25

标签: flutter firebase-cloud-messaging

我正在尝试从codeigniter模块向我的flutter应用程序发送推送通知。 我的onResume和onLaunch无法正常工作。

我有2种情况

  1. 如果该应用程序处于打开状态,那么我只能在Flutter控制台中打印消息(通知栏中没有数据显示,也没有声音)。
    1. 如果该应用程序在后台运行,我什至无法打印任何消息,甚至没有来自fcm的声音/通知。

我的php数据有效载荷如下:

{ "data": {
"title": "Test FCM Notification",
"is_background": true,
"message": "Test notification message from gomax CRM",
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"image": "https://firebase.google.com/_static/9f55fd91be/images/firebase/lockup.png",
"payload": {
  "notification": ""
},

“时间戳记”:“ 2020-03-16 8:36:59” }}

我的颤动代码是:

_firebaseMessaging.configure(
    onMessage: (Map<String, dynamic> message) async{
      print("message on open: $message");
    },
    onResume: (Map<String, dynamic> message) async{
      print("messageon resume: $message");
    },
    onLaunch: (Map<String, dynamic> message) async{
      print("message on launch: $message");
    },
  //onBackgroundMessage:
);

和我的androidmenifest文件:

<intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <action android:name="FLUTTER_NOTIFICATION_CLICK"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>

0 个答案:

没有答案