I am using NB6 to display notifications.
If the app is in the foreground when the notification arrives and I click on it, it takes me to the indicated page, but if the app is in the background when I click on the notification, it disappears and does not take me to the indicated page.
How can I make it so that when I click on the notification it shows me the app, whether it is active or not?
Hi! The subject of my post explains what I need: I use the simple notification class to create a simple notification. Dim n As Notification If n.IsInitialized == False Then n.Initialize n.Sound = False n.Insistent = False n.Vibrate = False n.Icon = "icon" n.Light =...
Dim N As NB6
N.Initialize("default", Application.LabelName,"DEFAULT")
N.AutoCancel(True)
N.SmallIcon(LoadBitmap(File.DirAssets,"icon.png"))
N.OldNotificationIcon("icon")
N.OnGoing(True)
N.Build(Texto,Titulo,"miTag" & Valor, Main ).Notify(1)
I have added in Main
B4X:
Sub Activity_Resume
B4XPages.Delegate.Activity_Resume
B4XPages.MainPage.ActivityResume ' <-- This line
End Sub
And in B4MainPage
B4X:
Public Sub ActivityResume
Dim in As Intent = B4XPages.GetNativeParent(Me).GetStartingIntent
If in.IsInitialized And in <> LastIntent Then
LastIntent = in
If in.HasExtra("Notification_Tag") Then
Dim Tag As String = in.GetExtra("Notification_Tag")
Dim Linea As Int
B4XPages.ShowPage("Tramites")
pgTramites.VerTramite(Tag)
End If
End If
End Sub
If the app is in the foreground when I click on the notification it shows me the page "Tramites", if it is in the background it does nothing.
I generated the notification when I got a message from FireBase, the problem was in the message that already included a notification.
If the message is:
JSON:
notification {
title=titulo,
body=body of notification,
}
data {
campo1=valor1,
campo2=valor2,
}
When I receive the message with the app in the background it puts the message notification and when I click on it the app doesn't know about it.
But if the message is:
JSON:
data {
campo1=valor1,
campo2=valor2,
}
When I receive the message to the app creates the notification, when I click on the notification the app knows tanato this in foreground or background.
I comment it in case someone can help you.
Thanks