【发布时间】:2017-12-06 06:01:56
【问题描述】:
我通过PHP向android发送了一个通知,在android上就正常了。
但是当我发送多个时,它只显示最后一个,我希望它显示所有。
有可能吗?
我该怎么做?
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;
安卓
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());
【问题讨论】:
标签: php android firebase android-notifications