Send Onesignal notification using php api : 不考虑onesignal通知的参数"send_after"
Send Onesignal notification using php api : The parameter "send_after" of onesignal's notification is not taken into consideration
我正在使用 php/symfony 4 开发一个项目,在创建对象后,我发送了一个推送通知,通常没有指定传递参数“send_after”,它运行良好,移动设备会实时收到通知。
但是当我指定交货日期时,他们不考虑它,它是在我创建对象的那一刻发送的,这是我的代码片段:
$fields = array(
'app_id' => $this->api_key,
'include_player_ids' => $devices,
'data' => array(
"type" => $type,
"url" => $url
),
'contents' => $content
);
if (null != $dateTime) {
date_time_set($dateTime, 9, 0, 0);
array_push($fields, [
'send_after' => $dateTime->format('Y-m-d H:i:s TO')] );
}
$fields = json_encode($fields);
所以我尽量遵守文档中提到的这种格式:“2015-09-24 14:00:00 GMT-0700”
请问如果有人遇到过这个问题,我该如何解决?
提前致谢。
这应该有效:
$fields = array(
'app_id' => $this->api_key,
'include_player_ids' => $devices,
'data' => array(
"type" => $type,
"url" => $url
),
'contents' => $content
);
/* $dateTime=date_create("2020-08-12"); */
if (null != $dateTime) {
date_time_set($dateTime, 9, 0, 0);
/* $send_after = date_format($dateTime,'Y-m-d H:i:s TO'); */
$fields['send_after'] = $dateTime->format('Y-m-d H:i:s TO')] ); /* $send_after */
}
$fields = json_encode($fields);
我正在使用 php/symfony 4 开发一个项目,在创建对象后,我发送了一个推送通知,通常没有指定传递参数“send_after”,它运行良好,移动设备会实时收到通知。 但是当我指定交货日期时,他们不考虑它,它是在我创建对象的那一刻发送的,这是我的代码片段:
$fields = array(
'app_id' => $this->api_key,
'include_player_ids' => $devices,
'data' => array(
"type" => $type,
"url" => $url
),
'contents' => $content
);
if (null != $dateTime) {
date_time_set($dateTime, 9, 0, 0);
array_push($fields, [
'send_after' => $dateTime->format('Y-m-d H:i:s TO')] );
}
$fields = json_encode($fields);
所以我尽量遵守文档中提到的这种格式:“2015-09-24 14:00:00 GMT-0700”
请问如果有人遇到过这个问题,我该如何解决?
提前致谢。
这应该有效:
$fields = array(
'app_id' => $this->api_key,
'include_player_ids' => $devices,
'data' => array(
"type" => $type,
"url" => $url
),
'contents' => $content
);
/* $dateTime=date_create("2020-08-12"); */
if (null != $dateTime) {
date_time_set($dateTime, 9, 0, 0);
/* $send_after = date_format($dateTime,'Y-m-d H:i:s TO'); */
$fields['send_after'] = $dateTime->format('Y-m-d H:i:s TO')] ); /* $send_after */
}
$fields = json_encode($fields);