1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question Activity_Resume Intent not showing

Discussion in 'Android Questions' started by lucasheer, Aug 23, 2019.

  1. lucasheer

    lucasheer Member Licensed User

    Hello! I'm working on Firebase Push Notifications, and the extra data is not showing.

    Here is how I push the notification:

    Code:
    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:
    Code:
    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: Aug 23, 2019
  2. DonManfred

    DonManfred Expert Licensed 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?
     
    lucasheer likes this.
  3. lucasheer

    lucasheer Member Licensed User

    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
     
  4. DonManfred

    DonManfred Expert Licensed User

    how are you creating the notification? Post your code inside messagearived event
     
    lucasheer likes this.
  5. lucasheer

    lucasheer Member Licensed User

    Code:
    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!
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Change the SetInfo line to:
    Code:
    n.SetInfo2(myTitle, Message.GetData.Get("body"), "test!!!",  Main)
    What is the output of Log(in.ExtrasToString) in Activity_Resume?
     
    lucasheer likes this.
  7. lucasheer

    lucasheer Member Licensed User

    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:
    Code:
    Dim in As Intent
        
    in = Activity.GetStartingIntent
        
    Log(in.ExtrasToString)
     
  8. lucasheer

    lucasheer Member Licensed 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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice