我已经遍历了Firebase文档的每个步骤,但是问题是
发送多个通知时,最终用户的android设备已断开其Internet连接,打开Internet后,该设备仅接收到一个通知,仅接收到最新的通知。
这使此功能用很少或没有用。 有人遇到同样的事情吗? 怎么做?
答案 0 :(得分:0)
public static int NOTIFICATION_ID = 1;
private PendingIntent pendingIntent
pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.xchat_icon_push)
.setContentTitle(title)
.setContentText(messageBody)
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (NOTIFICATION_ID > 1073741824) {
NOTIFICATION_ID = 0;
}
notifManager.notify(NOTIFICATION_ID++, notificationBuilder.build());