早上好
我已经制作了一个Web服务php来安排fcm中的推送通知,该通知工作得很好,但是在我的项目中,我需要这些通知在特定时间到达,我应该发送什么数据,以便Firebase可以在我需要什么时间?
这是php代码:
<?php
if(isset($_GET['send_notification'])){
send_notification ();
}
function send_notification()
{
define( 'API_ACCESS_KEY', 'MY_KEY');
$msg = array
(
'body' => 'Firebase Push Notification',
'title' => 'Title notification.',
);
$fields = array
(
'to' => $_REQUEST['token'],
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
#Send Reponse To FireBase Server
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
echo $result;
curl_close( $ch );
}
?>
谢谢您的回答