Android 通过google推送通知从额外密钥接收旧值
我在收到谷歌推送通知时面临以下问题。 我正在提交以下来自PHP的通知,并为android GCMBaseIntentService中的receive unique id添加一个标记data.notificationIDAndroid 通过google推送通知从额外密钥接收旧值,android,push-notification,google-cloud-messaging,Android,Push Notification,Google Cloud Messaging,我在收到谷歌推送通知时面临以下问题。 我正在提交以下来自PHP的通知,并为android GCMBaseIntentService中的receive unique id添加一个标记data.notificationID $data = array( 'registration_id' => $deviceToken, 'collapse_key' => $collapseKey, 'data.messag
$data = array(
'registration_id' => $deviceToken,
'collapse_key' => $collapseKey,
'data.message' => $messageText ,
'data.notificationID' => $yourKey
);
通知正确发出,但notificationID值较旧,我已先推送该值。这不是锁链。但是data.message字符串是我最近发送的
php中的推送通知代码是:
<?php
$Key = "0000000";
$deviceToken = "sdfsjdfljsd";
$collapseKey = 1;
$messageText = "Hi welcome";
//$yourKey = 100;
$yourKey = 101;
$headers = array('Authorization:key=' . $Key);
$data = array(
'registration_id' => $deviceToken,
'collapse_key' => $collapseKey,
'data.message' => $messageText ,
'data.notificationID' => $yourKey
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://android.googleapis.com/gcm/send");
if ($headers)
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
return false;
}
if ($httpCode != 200) {
return false;
}
curl_close($ch);
?>
在下面的一行中,我的notificationID变老了,但每次我提交新id时
generateNotification(arg0、arg1.getStringExtra(“消息”)、arg1.getStringExtra(“通知ID”)
如果有bug,请帮助我找出。这是一个常见问题,未更新挂起的意图, 就这样改变吧:
PendingIntent intent = PendingIntent.getActivity(context, 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
这是一个php问题,因为您的服务器部分似乎弄错了……谢谢@Anis!非常有帮助,我一直想知道为什么我的GCM意图数据在过去两天没有更新@gauravsanu请接受答案:)
PendingIntent intent = PendingIntent.getActivity(context, 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);