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
 

Alex_197

Well-Known Member
Licensed User
Longtime User
check highlighted line

B4X:
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
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
check highlighted line

B4X:
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

He is using NB6 (Notification builder)
 
Upvote 0
Top