有没有办法一次发送多个推送消息?
昨天发送 100 条消息需要 38 秒,太长了。
我只获得一次授权 token ,我使用:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://android.apis.google.com/c2dm/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: GoogleLogin auth=$authCode"));
$post_fields = "registration_id=" . urlencode($deviceToken)
. "&".$payload
. "&collapse_key=$key";
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
$response = curl_exec($ch);
curl_close($ch);
if (strpos($response, '200 OK') !== false) {
return true;
}
else echo $response." ";
return false;
对于我得到的每个推送 token 。
有没有更快的方法?
谢谢
最佳答案
curl_multi_exec 就是答案。
关于android - 使用 c2dm 一次发送多个推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5323564/