嗨,我發送通知到Android手機從PHP服務器。它的工作正常與單個通知。但是,如果我一次發送2個通知。第一次通知將由第二次通知取代。有什麼辦法可以在排隊中看到2個通知(即像短信收件箱消息格式)。如何在排隊中發送谷歌雲消息?
下面是我的PHP代碼:
<?php
define("GOOGLE_API_KEY", "API id");
define("GOOGLE_GCM_URL", "https://android.googleapis.com/gcm/send");
function send_gcm_notify($reg_id, $message) {
$fields = array(
'registration_ids' => array($reg_id),
'data' => array("message" => $message),
);
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, GOOGLE_GCM_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Problem occurred: ' . curl_error($ch));
}
curl_close($ch);
echo $result;
}
$reg_id = "device id";
$msg = "Google Cloud Messaging working well";
for($i=0;$i<=3;$i++){
send_gcm_notify($reg_id, $msg);}
是的,你可以做到這一點,通過附加一些標識文字,你可以說組ID,商店中的所有郵件本地數據庫,同時顯示你可以顯示它像聊天 –