0

I want to stack Firebase notifications. I tried the one from this post, but it didn't work.

How can I do that? Here's my code. Thanks.

public class FirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        showNotification(remoteMessage.getData().get("message"));
    }

    private void showNotification(String message) {

        Intent i = new Intent(this,MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);        
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setAutoCancel(true)
                .setContentTitle("test")
                .setContentText(message)                
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentIntent(pendingIntent);

        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        manager.notify(0,builder.build());
    }
}
Community
  • 1
  • 1
Joe J.
  • 19
  • 1
  • 6
  • I don't see the `.setGroup()` anywhere in your code. Can you elaborate how the post you referred to didn't work for you? Is the notification still just piling up? – AL. Jan 05 '17 at 02:35
  • Similar questions have already been asked (see [this](http://stackoverflow.com/a/39715021/4625829) and [this](http://stackoverflow.com/a/40395278/4625829)) and I have just referred them to refer to the docs, where it is explained thoroughly. – AL. Jan 05 '17 at 02:37

0 Answers0