未获得有关cordova 推送通知的完整信息cordova-plugin-firebasex

问题描述

我正在开发一个需要推送通知的 Cordova 应用程序。对于推送通知,我使用了 cordova-plugin-firebasex plugin 。当应用程序处于前台但当应用程序为后台推送通知显示通知栏上时它运行良好但当我单击它时不显示标题,正文和其他数据。目前它显示以下消息:

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代码如下:

-

   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);

我的 PHP 代码如下:

-

$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","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,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);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)