我不确定这是否完全可行,但我会陈述我的要求。如果有可能,那么请好好帮我弄清楚如何去做。fcm通知类似于whatsapp,但允许多个组通知
比方说,我有一个类似的Android应用程序。当用户喜欢上或在图库中的照片的评论,我们会使用以下
value++;
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification)
.setLargeIcon(rawBitmap)
.setContentTitle("MyApp")
.setContentText(ContentText)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setDefaults(Notification.DEFAULT_SOUND)
.setStyle(new NotificationCompat.BigTextStyle().bigText(ContentText))
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(value, notificationBuilder.build());
给出的代码通过添加InboxStyle我们可以组notifcations到一个单一的一个,只是增加了计数,触发FCM通知。(例如你有5个通知)
NotificationCompat.InboxStyle inboxStyle =
new NotificationCompat.InboxStyle();
// Sets a title for the Inbox in expanded layout
inboxStyle.setBigContentTitle("Title - Notification");
inboxStyle.setSummaryText("You have "+value+" Notifications.");
notificationBuilder.setStyle(inboxStyle);
但我的要求就像分开的照片单独分组。如果用户为每张照片留下2条评论。我需要列出三组通知。更像是你对这张照片有2条评论,对此有2条评论等等。
我会收到照片的唯一ID,如果有帮助。
How long will the id be retained?
假设用户滴在照片2条评论id为001和合作伙伴收到通知为一组。
What happens when the user drops another 2 comments on photo with id 002?
Will there be 2 groups?
因为ID为001的一组通知保持不变。
您可以使用['tag'](https://firebase.google.com/docs/cloud-messaging/http-server -ref#notification-payload-support)参数并传递照片的唯一标识。 –
使用'photo unique id'作为通知ID,它应该没问题。他们将按通知ID进行分组。 – Shark
ID会保留多久? 让我们假设用户在ID为001的照片上放下2条评论,并且合作伙伴收到作为一个组的通知。 当用户在ID为002的照片上放下另外2条评论时会发生什么? 会有2组吗? 由于ID为001的一组通知保持不变。 –