如何使用PHP发送带有大图像的单信号推送通知
代码只发送标题和消息,但未收到图标。我是一个新的信号API。这是我的密码:如何使用PHP发送带有大图像的单信号推送通知,php,onesignal,Php,Onesignal,代码只发送标题和消息,但未收到图标。我是一个新的信号API。这是我的密码: <?php $fields = array( 'app_id' => 'my app id', 'include_player_ids' => ['player_id'], 'contents' => array("en" =>"test message"), 'headings
<?php
$fields = array(
'app_id' => 'my app id',
'include_player_ids' => ['player_id'],
'contents' => array("en" =>"test message"),
'headings' => array("en"=>"test heading"),
'largeIcon' => 'https://cdn4.iconfinder.com/data/icons/iconsimple-logotypes/512/github-512.png',
);
$fields = json_encode($fields);
//print("\nJSON sent:\n");
//print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Authorization: Basic M2ZNDYtMjA4ZGM2ZmE5ZGFj'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
?>
图标的键应该是
大图标
而不是大图标
选中您只需添加:
“chrome\u web\u图像”=>“图像url”;
如需进一步阅读,请访问:
结果:
您可以使用
ios\u attachments
参数,它必须在数组中
我就是这样做的:
$iCon = array(
"ios_attachments" => 'https://Your.Image.png'
);
$fields = array(
// OneSignal - Personal ID
'app_id' => "Your_OneSignal_ID",
'included_segments' => array('All'),'data' => array("foo" => "bar"),
// Submitting Title && Message && iCon
'headings' => $headings,
'contents' => $content,
'ios_attachments' => $iCon,
);
@那是chrome通知我想发送到移动设备移动你的身份验证详细信息@马力努斯,这不是我的全部授权。
$iCon = array(
"ios_attachments" => 'https://Your.Image.png'
);
$fields = array(
// OneSignal - Personal ID
'app_id' => "Your_OneSignal_ID",
'included_segments' => array('All'),'data' => array("foo" => "bar"),
// Submitting Title && Message && iCon
'headings' => $headings,
'contents' => $content,
'ios_attachments' => $iCon,
);