1

I'm creating local push notifications, which is working fine. If the user has more than three open push notifications, the device (Samsung tablet) is grouping them together. Now the issue begins. If the user taps on the group notification summary my app is opened like it was never started (but it is running in foreground at the moment).
The OnCreate() method of MainActivity is called, which in turn calls LoadApplication(new App()); and in App.xaml.cs my first page is pushed on to the navigation stack.

If I expand the summary, I can click the separate push notifications and OnNewIntent() is called like desired.

I tried to add LaunchMode = LaunchMode.SingleTop to the MainActivity, but it didn't change something. Then I tried to use ActivityFlags.SingleTop, when creating the notification with the same result

How can I improve the behavior so that it doesn't push a new page onto the view?

testing
  • 19,681
  • 50
  • 236
  • 417
  • have you try it on other devices?Usually you set the `LaunchMode = LauncMode.SingleTop` ,it will be called in `OnNewIntent()`,and you also could try to set the launchMode in `AndroidMainfest.xml`, – Leo Zhu Oct 03 '19 at 06:51
  • @LeoZhu-MSFT: How do I set the launch mode in `AndroidManifest.xml`? I only have the `application` tag and no `activity` tag. But I think [Saamer](https://stackoverflow.com/a/58208047/426227) is right, because the link he posted states "*If your app sends four or more notifications and does not specify a group, the system automatically groups them together on Android 7.0 and higher.*". The question is how should I handle that situation? – testing Oct 03 '19 at 09:37
  • like ` ` in your `` – Leo Zhu Oct 08 '19 at 07:38

1 Answers1

1

Most likely it's because the Samsung Tablet has a version of >= Android N or API 7.0. You need to use Notification Groups (not Channel Groups since you mentioned it's not >8.0) in order to handle the opening of notifications properly.

Android can be difficult. Here's a good resource from the official android documentation on how to do that.

How you set the group and how you get the groupID on tapping the notification.

Saamer
  • 4,687
  • 1
  • 13
  • 55
  • The tablet has Android 7.1.1 running. If I read this correct I have to create a group notification? The thing is, that I don't know when I should create such a group notification. I would have to build a cache to know, that there are more than three notifications? How do I specifiy the action which should get executed, when the user taps on the group notification? Currently, I'm not targeting Android 8 - so notification channels shouldn't be a topic for now. – testing Oct 03 '19 at 09:30
  • Updated this broski with more details – Saamer Oct 03 '19 at 16:07
  • Thanks for the update. So I have to first create the group notification and then the separate single notifications? How do I know when to create a group notification? The events when the single notifications are created are out of my control (I don't know them in advance). The only way would be a cache or something like that. But how long do you collect the notifications (and not showing to the user)? The grouping by the system occurs if there are more than three. In addition, the notifications should be shown immediately to the user and not one hour later. How can I handle that? – testing Oct 04 '19 at 08:36