微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决未获得有关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 举报,一经查实,本站将立刻删除。