0

I am using Firebase to generate a remote notification for my App.

My Activity chain is as follows

Splash Activity (Launchmode SingleTask, NoHistory = True)

calls

Login Activity (Launchmode Standard (default), NoHistory = True)

calls

Main Activity (Launchmode SingleTask, NoHistory = False)

If I place my App in the background (main activity has Paused) and rerun it from the desktop, the Resume event fires in the main activity and all is well.

However if I place the App in the background (main activity has Paused) and select a notification for the App from the Notification List on the desktop, the Splash Activity Create method fires.

How can I make the behaviour for Notification triggering be the same as for resuming from background. I dont want the user to login every time they click on a notification.

Thanks

MHugh
  • 455
  • 1
  • 7
  • 20
  • I have found that setting NoHistory=False in the Main Activity gives me the behaviour I was looking for, i.e. Create does not now fire, but it resumes. However. since I am trying to handle a notification, I am trying to pass the Intent data from the Splash Activity through to the Main Activity. This works if the Activity is Created, but now I have worked around that to just Resume the existing Activity, the intent with the notification data is no longer passed. The question now becomes; how do I pass an intent to an Activity which is being resumed rather than created ? – MHugh Oct 23 '17 at 15:03

1 Answers1

0

how do I pass an intent to an Activity which is being resumed rather than created ?

You should implement OnNewIntent(Intent intent) in your MainActivity. You can then use that to set the 'current' Intent to be the new Intent.

protected override void OnNewIntent(Intent intent)
{
    if (intent != null)
        Intent = intent;
    base.OnNewIntent(intent);
}

Then in OnResume() you can use the intent to restore your notification data.

Intent intent = Intent;
York Shen
  • 9,014
  • 1
  • 16
  • 40