Android Question Activity_Resume Intent not showing

lucasheer

Active Member
Licensed User
Longtime User
Hello! I'm working on Firebase Push Notifications, and the extra data is not showing.

Here is how I push the notification:

B4X:
Dim n As Notification '//android only
        Dim myTitle As String = Message.GetData.Get("title")
        myTitle=myTitle.ToLowerCase()
        If(myTitle.contains("message")) Then 'is a message notification
            n.Initialize
            n.Icon = "icon"
            n.SetInfo2(myTitle, Message.GetData.Get("body"), myTitle,  Main)
            n.Notify(4)
        End If

And in the activity_resume, I get here fine:
B4X:
Dim in As Intent
    in = Activity.GetStartingIntent
    Log("we are here")
    If in.HasExtra("Notification_Tag") Then
        Log(in.GetExtra("Notification_Tag")) 'Will log the tag
    End If

Whenever I tap the notification, I get the first log message perfectly, "we are here", but the Notification_Tag is not getting logged. Has anyone else had this issue? Any help is much appreciated.

Thank you!
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Do you have a foreground service and click on the Notification for this foreground service instead of the notification which are created in the firebasemessaging service?
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
Do you have a foreground service and click on the Notification for this foreground service instead of the notification which are created in the firebasemessaging service?

I'm using the firebasemessaging service. The notification is created just fine, even when the app is not running in the background. But it does not give me anything whenever my activity_resume is called in the Main activity
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
how are you creating the notification? Post your code inside messagearived event

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
       Dim n As Notification
        Dim myTitle As String = Message.GetData.Get("title")
        myTitle=myTitle.ToLowerCase()
        If(myTitle.contains("message")) Then 'is a message notification
            n.Initialize
            n.Icon = "icon"
            n.SetInfo2(myTitle, Message.GetData.Get("body"), myTitle,  Main)
            n.Notify(4)
        End If
End Sub

This is what I have for messagearrived. I'm going to test it on a different device on Monday.

Thank you!
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
Change the SetInfo line to:
B4X:
n.SetInfo2(myTitle, Message.GetData.Get("body"), "test!!!",  Main)

What is the output of Log(in.ExtrasToString) in Activity_Resume?

Yes sir! I did this change, and somehow I got my data! I never even added the data to the push notification.

Bundle[{google.delivered_priority=high, message_id=2, google.sent_time=1566826144838, google.ttl=2419200, google.original_priority=high, message_content=fj, from=357248794806, google.message_id=0:1566826144862703%c3f81058c3f81058, collapse_key=com.central.dealerships}]

message_id=2
message_content=fj

However, I did not get the "test!!!" Data. Any advice on why?


New Activity_Resume code:
B4X:
Dim in As Intent
    in = Activity.GetStartingIntent
    Log(in.ExtrasToString)
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
Using the Extras "message_id" and "message_content", which i set from the firebase API, seems to work fine. I'm just concerned, because I never set the in the Dim n As Notification.

Works great now! Thank you! @DonManfred @Erel
 
Upvote 0
Top