我正在使用PHP向特定的Android应用程序用户发送firebase推送通知。
function enviar_push($token,$titulo,$subtitulo){
define( 'API_ACCESS_KEY', 'AAA.....');
// $registrationIds = ;
#prep the bundle
$msg = array
(
'body' => $subtitulo,
'title' => $titulo,
'subtitle' => ''
);
$fields = array
(
'to' => $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 );
}
出于某种原因,推送通知只到达一些设备,而不是所有设备。
有什么理由吗?
如果我直接从Firebase控制台发送通知,所有设备都将到达。