i folgenden Code bin mit Push-Benachrichtigungen an ein Android-GerätFirebase: php Push-Benachrichtigung auf mehrere Devics
function send_notification($message, $token){
define('API_ACCESS_KEY', 'mykey');
$msg = array
(
'body' =>$message,
'title' => 'You have a new message ',
);
$fields = array
(
'to' => $token,
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'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($fields));
$result = curl_exec($ch);
echo $result;
curl_close($ch);
}
i erfolgreich es was zu einem Gerät zu senden bin zu senden, wenn ich es an mehrere Geräte-IDs senden möchten Wo muss ich loopen und welche Formatdaten wären das? Bitte helfen Sie
sollte es so sein 'zu' \t \t => [2,3,4,5] – Sikander
Kein @Sikander, sollte es eher so aussehen: ' $ fields = array ( 'registration_ids' => [2,3,4,5], ... ); '' ' –
wie? Ich meine, bitte klar – Sikander