Ich sende eine Benachrichtigung an Android durch PHP, und es wird normal auf Android.android Benachrichtigung Firebase
Aber wenn ich mehr als eins sende, wird nur das letzte angezeigt, und ich wollte, dass es alle anzeigt.
ist es möglich?
Wie kann ich das tun?
PHP
$msg = array
(
'nome' => $comando,
);
$fields = array
(
'to' => $token,
'data' => $msg
);
$headers = array
(
'Content-Type: application/json',
'Authorization: key= KEY'
);
#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);
curl_close($ch);
#Echo Result Of FireBase Server
echo $result;
android
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1410,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new
NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setSound(alert)
.setContentTitle("teste")
.setContentText("teste "+msg+"!")
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.setPriority(2)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1410, notificationBuilder.build());
Wenn diese Antwort Ihnen hilft, dann können Sie es als richtige Antwort akzeptieren, indem Sie das Häkchen markieren. – Dharmishtha