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:
- How to bring the App to the foreground when the alarm triggers, without the user having to tap on a Notification.
- 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).