未获取有关cordova(cordova插件firebasex)推送通知的完整信息

未获取有关cordova(cordova插件firebasex)推送通知的完整信息,cordova,cordova-plugin-firebasex,Cordova,Cordova Plugin Firebasex,我正在开发一个Cordova应用程序,需要推送通知。对于推送通知,我使用了cordova插件firebasex插件。当应用程序是前台时,它工作良好,但当应用程序是后台时,在通知栏上推送通知显示,但当我单击它时,它不会显示标题、正文和其他数据。当前它显示以下消息: collapse_key: "com.hadi.storex" from: "383656394813" google.delivered_priority: "normal&q

我正在开发一个Cordova应用程序,需要推送通知。对于推送通知,我使用了cordova插件firebasex插件。当应用程序是前台时,它工作良好,但当应用程序是后台时,在通知栏上推送通知显示,但当我单击它时,它不会显示标题、正文和其他数据。当前它显示以下消息:

collapse_key: "com.hadi.storex"  
from: "383656394813"  
google.delivered_priority: "normal"  
google.message_id: "0:1620737447755747%7dc0077a7dc0077a"   
google.original_priority: "normal"   
google.sent_time: 1620737447734   
google.ttl: 2419200   
messageType: "notification"   
tap: "background"   
我的js代码如下:

-

我的PHP代码如下:

-


在fcm服务器上发送数据的正确方法是

$fields=数组(

   function onDeviceReady() {
          FirebasePlugin.getToken(function (fcmToken) {
          console.log(fcmToken);    }, function (error) {
          console.error(error);    });    FirebasePlugin.onTokenRefresh(function (fcmToken) {
          console.log(fcmToken);    }, function (error) {
          console.error(error);    });    FirebasePlugin.onMessageReceived(function (message) {
          console.log("Message type: " + message.messageType);
          if (message.messageType === "notification") {
              console.log("Notification message received");
              if (message.tap) {
                  console.log("Tapped in " + message.tap);
              }
          }
          console.dir(message);
         }, function (error) {
             console.error(error);
         });    }
       document.addEventListener("deviceready", onDeviceReady, false);
$path_to_fcm = "https://fcm.googleapis.com/fcm/send";   
       $headers = array(    
          'Authorization:key=' . FCM_SERVER_KEY,    
          'Content-Type:application/json');     
   
   $fields = array(

       "to" => 'registration_ids',

       'notification' => array(
           'title' => "title of notification1122",
           'body' => "your notification goes here22233",
           "surveyID" => "ewtawgreg-gragrag-rgarhthgbad",
           "data" => array(
               'title' => "title of notification1122",
               'body' => "your notification goes here22233",
               "notification_body" => "Notification body",
               "notification_title" => "Notification title",
               "surveyID" => "ewtawgreg-gragrag-rgarhthgbad"
           )
       )
   );

   $payload = json_encode($fields);


   $curl_session = curl_init();

   curl_setopt($curl_session, CURLOPT_URL, $path_to_fcm);
   curl_setopt($curl_session, CURLOPT_POST, true);
   curl_setopt($curl_session, CURLOPT_HTTPHEADER, $headers);
   curl_setopt($curl_session, enter code hereCURLOPT_RETURNTRANSFER, true);
   curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($curl_session, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
   curl_setopt($curl_session, CURLOPT_POSTFIELDS, $payload);

   $curl_result = curl_exec($curl_session);
   print_r($curl_result);
        'notification' => array(
            'title' => "title of notification1122",
            'body' => "your notification goes here22233",
            "sound" => "default",
            "click_action" => "FCM_PLUGIN_ACTIVITY",
            "icon" => "fcm_push_icon"
        ),
        "data" => array(
            "param1" => "value1",
            "param2" => "value2"
        ),
        "to" => any device device token or topic like "/topics/topicName" , 
        "priority" => "high",
        "restricted_package_name" => ""
    );

    $payload = json_encode($fields);