小编Ife*_*ayo的帖子

GCM android PHP android推送通知

我的问题与使用PHP curl的android推送通知有关.问题是我向我的Android设备发送一个推送通知,但问题是我的一些设备不止一次获得该通知,有时20次,而有些只获得一次,因此排除了应用程序的错误.我真的不知道问题是什么.感谢您的预期响应/解决方案.请参阅下面的推送代码

function googlePush($DevID, $Message , $id)
{
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
//  static $a=1;
    $DeviceID = array($DevID);
$Message = array("MSG" => $Message, "MSGCNT" => $Message, "message" => $Message, "id" => $id);

$fields = array(
    'registration_ids' => $DeviceID,
    'data' => $Message,
);

$headers = array(
    'Authorization: key=' . 'xxxxxxxxxxxxxxxxxxxxxxxx',
    '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); …
Run Code Online (Sandbox Code Playgroud)

android push-notification google-cloud-messaging

0
推荐指数
1
解决办法
3139
查看次数