Я хочу, чтобы установить данные для отправки FirebaseFirebase локон добавить данные
function sendFCM($body,$id,$title,$url) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
'to' => $id,
'notification' => array (
"body" => $body,
"title" => $title,
"icon" => $url,
AND HERE???? HOW SET DATA?
'data' => array (
"id_notification" => $id_notification
)
)
);
$fields = json_encode ($fields);
$headers = array (
'Authorization: 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_POSTFIELDS, $fields);
$result = curl_exec ($ch);
curl_close ($ch);
}
Я обновить код :::::::
Firebasemessaging
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
UrI alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if(alarmSound == null){
alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
}
String Body = remoteMessage.getNotification().getBody();
String Titolo = remoteMessage.getNotification().getTitle();
String Icona = remoteMessage.getNotification().getIcon();
String TAG = remoteMessage.getNotification().getTag();
String Colore = remoteMessage.getNotification().getColor();
sendNotification(Body,Titolo,Icona,TAG,Colore);
}
И в Android в MessageReceiver()
как получить данные? Например, я хочу получить id_notification
.
Спасибо всем за помощь!
, что вы имеете в виду 'id_notification' – Selvin
идентификационным уведомления –
тот, который вы еще не послать или один из' NotificationManager.notify' (который также не называется) ... ну, возможно, путешествие во времени будет доступно в будущем ... – Selvin