我尝试使用Firebase发送通知,发送了通知,但没有自定义声音。
我听到了声音,但是当我尝试替换声音时,我仍然听到默认声音
这是我的代码:
<?php
$payload = array(
'to'=>'/topics/TOPIC_NAME',
'priority'=>'high',
"mutable_content"=>true,
"notification"=>array(
"title"=> 'TEST',
"body"=> 'Hello',
"sound"=> "alert.mp3" //=> I tried also "alert"
)
);
$headers = array(
'Authorization:key = AIza......',
'Content-Type: application/json'
);
$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( $payload ) );
$result = curl_exec($ch );
curl_close( $ch );
var_dump($result);
?>
我将声音文件放入res / raw中。.请帮助我。谢谢!!!