4

I have implemented firebasse notification functionality in my chat app and everything is running fine but now while testing in Android os 8.0 and 8.1 when app is in background and if user is getting 4 or more than 4 notification then its combined in group and when user click on group then not getting intent and app is restarted.

If user tap on single notification then I am able to send him in specific screen.

I want Notification data or chat id so I can send him in specific screen but not getting any data in intent.

I have searched similar kind of question in stackoverflow but still not getting proper result.

Android: Clicking Grouped Notifications Restarts App

How to open non-launcher activity on notification group click

Pankaj K.
  • 535
  • 8
  • 18

2 Answers2

1

You can use setContentIntent to set the value of Intent like below

    Intent intent = new Intent(this, SecondActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.your_notification_icon)
                    .setContentTitle("Notification Title")
                    .setContentText("Notification ")
                    .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, mBuilder.build());

It will open SecondActivity (Replace the SecondActivity with your own activity)

Rabindra Khadka
  • 1,344
  • 1
  • 13
  • 23
0

I am having the same issue causing app restart in Oreo, after many tries i noticed that if when creating the notification i call .setGroup(string) the system no longer groups the notifications.I am creating the notifications from a service. This is not a solution i know but not grouping is a lesser evil than app restart.

IulianT
  • 350
  • 1
  • 3
  • 13