0

私はFirebaseでチャットアプリケーションを作成しています。 Firebase Cloudの機能を使って通知を送信し、電話で受信します。しかし、すべてのメッセージに対して私は新しい通知を受け取ります。そして今、WhatsAppのような通知を作成することが可能かどうか、1つの通知内の各メッセージに複数の行があるかどうかを知りたいと思います。通知のための私のコード:あなたの助けをChatApp:複数の通知

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    String notification_tag = remoteMessage.getData().get("senderUiD"); 

     Intent intent = new Intent(getApplicationContext(), Chat_Room.class); 

     PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0); 

     NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext()) 
       .setSmallIcon(R.mipmap.ic_launcher) 
       .setContentTitle(remoteMessage.getData().get("username")) 
       .setContentText(remoteMessage.getNotification().getBody()) 
       .setVibrate(new long[]{1500, 0, 1500, 0}) 
       .setLights(Color.BLUE, 2000, 1000) 
       .setWhen(remoteMessage.getSentTime()) 
       .setAutoCancel(true) 
       .setPriority(NotificationCompat.PRIORITY_HIGH) 
       .setStyle(new NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification().getBody())) 
       .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) 
       .setContentIntent(pendingIntent); 

     notificationManager.notify(notification_tag, 0, notificationBuilder.build()); 

感謝;)

+0

このリンクを読むことを強くお勧めします。https://stackoverflow.com/questions/33040737/how-to-group-android-notifications-like-whatsapp https://stackoverflow.com/questions/41692501/グループ通知 - アンドロイド –

答えて

0

あなたはNotificationメッセージオーバーライドであなたのNotificationを受けている最後のNotification

もRendam数

Random ran = new Random(); 
int notification_tag = r`an.nextInt(6) + 5;` 

notificationManager.notify(notification_tag, 0, notificationBuilder.build()); 

を生成します、通知をグループ化するためのステップが少し残っています

NotificationCompat.Builder:contains the UI specification and action information 
NotificationCompat.Builder.build() :used to create notification (Which returns Notification object) 
Notification.InboxStyle: used to group the notifications belongs to same ID 
NotificationManager.notify():to issue the notification. 
関連する問題