1

這是通知中發送消息和數據的代碼。發送自定義數據pushPlugin cordova php

$fields = array(
     'registration_ids' => $this->devices, 
     'data'    => array(
       "message"  => $message, 
       "msgcnt"  => "8", 
       "collapse_key" => "dffbb") 
     ); 

我現在面臨的問題是我無法發送msgcntcollapse_key旁邊別的。

快訊會提供未定義例如

$fields = array(
     'registration_ids' => $this->devices, 
     'data'    => array(
       "message"  => $message, 
       "msgcnt"  => "8", 
       "collapse_key" => "dffbb", 
       "test_field" => "test") 
     ); 
+0

我改進了格式;然而,在*之後仍然丟失瞭解釋,例如* ...請解釋* undefined *。什麼是未定義的? – hata

回答

1

您可以創建這樣的自定義數據另一個數組:

$fields = array(
       'registration_ids' => $this->devices, 
       'data'    => array("message" => array("text_message" => $message, "test_field" => "test"), 
              "msgcnt"=>"8", 
              "collapse_key"=>"dffbb", 
              ) 
      ); 
0

我知道了它獲取返回的數據進入另一個數組索引命名爲有效載荷所以如果你想在javascript中訪問它,你可以試試。

alert(e.payload.test_field);