我想在通过 Google Cloud Notifications 发送到应用程序的远程通知中添加一张图片。
我正在通过 PHP 将通知发送给 Google。这本身似乎与我找到的文档不太匹配,该文档告诉我发送“消息”参数,而实际上它是应用程序上显示的“警报”。
下面是我的 PHP 代码:
public function send_notification($registation_ids, $message) {
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
echo 'Message: '.$message.'<br>';
$fields = array(
'registration_ids' => $registation_ids,
'data' => array(
'message' => $message,
'alert' => $message
)
);
$headers = array(
'Authorization: key=' . GOOGLE_API_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);
// 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) {
return curl_error($ch);
}
// Close connection
curl_close($ch);
return $result;
}
我原以为我只需要连同负载一起发送一个图标,但我找不到任何文档来支持这一点。
另一种选择是将图标放在应用本身上,然后在负载中调用一个变量来引用该图标,但也找不到任何支持该图标的文档。
附带说明一下,该应用程序是使用 Corona SDK 构建的,但我不确定它的相关性如何。
如有任何帮助,我们将不胜感激。谢谢
最佳答案
事实证明,Corona 在项目的根目录中查找特定的文件名并使用它。有 3 种文件名格式,每种格式都有针对不同 DPI 的多个版本。目前,据我所知,您无法根据警报的负载更改此图标。
白色,适用于 Android 3.0+
IconNotificationDefault-ldpi-v11.png
IconNotificationDefault-mdpi-v11.png
IconNotificationDefault-hdpi-v11.png
IconNotificationDefault-xhdpi-v11.png
灰色,适用于 Android 2.3-3.0
IconNotificationDefault-ldpi-v9.png
IconNotificationDefault-mdpi-v9.png
IconNotificationDefault-hdpi-v9.png
IconNotificationDefault-xhdpi-v9.png
黑色,其他一切
IconNotificationDefault-ldpi.png
IconNotificationDefault-mdpi.png
IconNotificationDefault-hdpi.png
IconNotificationDefault-xhdpi.png
关于php - 修改 Android 推送通知(GCN)中操作栏中的应用程序图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22197241/