我想向Android发送通知。通知发送成功。但是,电话声音不起作用。我想在通过电话收到通知时给电话打电话。 这是我的代码:
$token=$_POST['token'];
$doctor=$_POST['d_name'];
$API_KEY = "AAAAVXABzCk:APA91bHVimlQAf6uRFc04YaX_JPMO5lN0NXcSVq0Q5W7uGU1iZnPEMR5crlIhEFkpjM2NGhF1bZRt5vfYdDyrt7OCqXmaUNKLOPhQ3ZxjW_R";
$url = 'https://fcm.googleapis.com/fcm/send';
$message= ['order_id' => 'hello'];
$notification = [
'title' => 'Appointment Confirmation',
'body' => $doctor.' is enabled your appointment. Please, open application.',
];
$fields = array (
"to" => 'fZ3Tx1hTR6Ca5ecJMM3SXi:APA91bGBzBNdGawDU5O-FKJrPmYDG9FvCInyUUvnEfyPAzsCgVeaJvlNM1SY9ZYtaLCtbVMNZdurvHQ1PyYgoJ2DBFK0GzWDHQ80P',
'notification' => $notification,
'data' => $message,
'vibrate'=>'1',
'sound'=>'default',
);
$fields = json_encode ( $fields );
$headers = array (
'Authorization: key=' . $API_KEY,
'Content-Type: application/json'
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
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, $fields );
$result = curl_exec ( $ch );
curl_close ( $ch );
echo $result;
?>