[英]content or data limit for Android push notification (GCM)
使用php的Android推送通知GCM是否有任何数据限制。 我通过此代码传递了数据(消息)。
$url = 'https://android.googleapis.com/gcm/send';
$fields = array (
registration_ids' => $registatoin_ids,
data => $message,
);
$headers = array(
Authorization: key= . GOOGLE_API_KEY,
Content-Type: application/json
);
// Open connection
if(!function_exists('curl_init'))
echo "CURL not installed";
else
$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);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
// Close connection
curl_close($ch);
$obj = json_decode($result);
if($obj->{'success'})
{
echo "Message Sent Successfully";
}
else{
echo "Sending Error : " . $result;
}
如果$ message包含超过3000个字符,则我没有收到任何通知。 假设如果$ message少于1000个字符,我会收到通知。
提前致谢。
是它的有效负载限制为4096字节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.