我必須針對大量設備(每天超過10k個設備)發送帶有不同消息的推送通知。但有時它不接收所有設備。我設置了一個功能pushNotificationToUsers($heading,$message,$registraionids)
發送推送通知和我不確定我的方法是否正確,如果我錯了,請糾正我。發送到GCM的大規模推送通知
function pushNotificationToUsers($heading,$message,$registraionids){
//array of registration ids in $registraionids
$key="xxxxxxxxxxx";
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' =>,$registraionids,
'data' => array("message" => $message,"title"=>$heading,"soundname"=>"beep.wav"),
);
$headers = array(
'Authorization: key=' . $key,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
}
我使用PHP在我的服務器端
我的方法正確嗎? – 2014-12-04 04:38:46
感謝讓我檢查 – 2014-12-04 04:41:59
接受&投票答案,如果它可以幫助你 – VVB 2014-12-04 04:42:45