0

We've got a background alarm service which is working fine, and which displays notifications when the alarm triggers.

We now want it to display a Page rather than a notification - even when the App is in the background.

Looking at the Android, documentation, I know that this is achievable using Xamarin.Android.

So I've got two questions here:

  1. How to bring the App to the foreground when the alarm triggers, without the user having to tap on a Notification.
  2. How to handle this in Xamarin.Forms.

For the second question, I think part of the solution is to detect whether the App is being started from a notification, with code similar to:

protected override void OnCreate(Bundle bundle)
{
  base.OnCreate(bundle);
  if(bundle.ContainsKey(ScheduledAlarmHandler.LocalNotificationKey)){
      //App launched form notification
    MessagingCenter.Send<MainPage> (this, "Android notification received");
  }
}

(the above gleaned from this StackOverflow post).

Community
  • 1
  • 1
James Lavery
  • 920
  • 4
  • 25

1 Answers1

0

You can use the below answer for the less security screen lock (Swipe/No Swipe) launch the activity with the below attributes.

https://stackoverflow.com/a/42509489/5610842

Community
  • 1
  • 1
RaghavPai
  • 652
  • 9
  • 14