我想設置數據發送火力地堡火力地堡捲曲添加數據
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