This is how I have implemented something like this, hope it helps.
In my Main.Actity_Create, I have this..
If FirstTime Then
LogColor("Request permissions..." , xui.Color_Magenta)
Dim c As RequestDrawOverPermission 'this is the name of the class
c.Initialize
Wait For (c.GetPermission) Complete (Success As Boolean)
LogColor("Permission granted: " & Success, xui.Color_Magenta)
'
Dim b As Boolean = CheckForGooglePlayServices
If b = False Then
MsgboxAsync("Google Play Services needs to be updated!","GPS")
End If
End If
When the app is installed, it asks for the permission to display over other pages. This happens once for the duration of the install.
If fm_MessageArrived sub on the FirebaseMessage service, I have..
If B4XPages.IsInitialized Then
B4XPages.MainPage.UpdateBadge
Dim ap As String = B4XPages.MainPage.ActivePage
Select Case ap
Case "pg1", "MainPage"
StartActivity(Main)
B4XPages.MainPage.NatigateTo("pg1")
Case "myloc"
mod.FromNotification = True
mod.NotificationPosition = data
StartActivity(Main)
B4XPages.MainPage.NatigateTo("myloc")
End Select
End If
So depending on the message received, I show the page that I need.
Then in Main.Activity_Resume, I have
Sub Activity_Resume
LogColor("Main.Resume...", Colors.Magenta)
B4XPages.Delegate.Activity_Resume
B4XPages.MainPage.ActivityResume
End Sub
Then in the MainPage I have..
Sub ActivityResume
LogColor("MainPage.Activity_Resume...", xui.Color_Magenta)
Dim in As Intent = B4XPages.GetNativeParent(Me).GetStartingIntent
If in.IsInitialized And in <> LastIntent Then
LastIntent = in
If in.HasExtra("Notification_Tag") Then
Dim stag As String = in.GetExtra("Notification_Tag")
mod.FromNotification = True
mod.NotificationPosition = mod.Json2Map(stag)
Dim smsgtype As String = mod.NotificationPosition.Get("msgtype")
Select Case smsgtype
Case "message", "registration"
B4XPages.ShowPage("pg1")
Case "08", "09", "03", "04"
If myloc.gmap.IsInitialized = False Then
Wait For (myloc.InitializeMap) Complete (Success As Boolean)
myloc.MapReady = Success
If myloc.MapReady Then
myloc.gmap.AddMarker(0, 0, "Center")
End If
End If
B4XPages.ShowPage("myloc")
End Select
Else
...
My app receives notifications, whether its running / not running, selecting the notification goes to the page I want.
Good luck