Android Question Problem to start app when click on push message from firebase

AndroidMadhu

Active Member
Licensed User
Hello,
I am trying to start the App on click on the firebase push message.
I am able to receive the push message, but upon click on the push message the app is not starting.
But I found several apps where I can start/open the app upon click on push messages.
Below is the code I have written...
B4X:
 Dim smiley As Bitmap
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)
smiley = LoadBitmapResize(File.DirAssets, "smiley.png", 24dip, 24dip, False)
Dim n1 As NB6
n1.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(smiley)
Dim cs As CSBuilder
Dim title As Object = cs.Initialize.Color(Colors.Red).Append(Message.GetData.Get("title")).PopAll
Dim Content As Object = cs.Initialize.Underline.Bold.Append(Message.GetData.Get("body")).PopAll
Dim largeIcon As Bitmap = LoadBitmapResize(File.DirAssets, "icon.png", 256dip, 256dip, True)
n1.LargeIcon(largeIcon)
n1.Color(Colors.Yellow)
n1.BadgeIconType("SMALL").Number(1)
n1.ShowWhen(DateTime.Now)
n1.Build(title, Content, "tag2", Me).Notify(5)

Please advice.

Thanks
 
check highlighted line

[CODE lang="b4x" highlight="20"]Try
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)

Dim n As Notification
Dim ID As Int=modFun.GetID

'n.Initialize
n.Initialize2(n.IMPORTANCE_HIGH)

n.AutoCancel=True
n.Sound=True

n.Icon = "icon"
n.Vibrate=True
n.Light=True



n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), MyActivity)

n.Notify(ID)

Catch
Log("fm_MessageArrived " & LastException)
modFun.ShowError("FirebaseMessaging_fm_MessageArrived " & LastException)
End Try[/CODE]
 
Upvote 0
check highlighted line

[CODE lang="b4x" highlight="20"]Try
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)

Dim n As Notification
Dim ID As Int=modFun.GetID

'n.Initialize
n.Initialize2(n.IMPORTANCE_HIGH)

n.AutoCancel=True
n.Sound=True

n.Icon = "icon"
n.Vibrate=True
n.Light=True



n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), MyActivity)

n.Notify(ID)

Catch
Log("fm_MessageArrived " & LastException)
modFun.ShowError("FirebaseMessaging_fm_MessageArrived " & LastException)
End Try[/CODE]

He is using NB6 (Notification builder)
 
Upvote 0
Back
Top