Android Question Incorrect notification message

Isac

Active Member
Licensed User
Longtime User
Hello

The message is recovered only when the app is open, then the message from b4j is not recovered, but what I wrote here:

B4X:
    Dim map As Map :map.Initialize
    map = CreateMap("title":"Test1", "body":"Test2")


This is what I see when the app is closed and immediately after sending the message.

Logger connesso a: HUAWEI BLN-L21
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **


When the app opens the log is this:

** Receiver (firebasemessaging) OnReceive **
** Service (firebasemessaging) Start **
Message arrived
Message data: ID 0:1531863143300168%959093b8959084b9, Data {}
Message=(RemoteMessage) com.google.firebase.messaging.RemoteMessage@1968a33
map=(MyMap) {title=Test1, body=Test2}
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
XTRA={"title":"Test1","body":"Test2"}
in=(Intent) Intent { flg=0x10020000 cmp=com.mio.read/.main (has extras) }
in ExtrasToString=Bundle[{Notification_Tag={"title":"Test1","body":"Test2"}}]



B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ID ${Message.MessageId}, Data ${Message.GetData}"$)
    Log("Message="& Message)
    Dim map As Map :map.Initialize
    map = CreateMap("title":"Test1", "body":"Test2")
    Log("map="&map)
    Dim jgen As JSONGenerator
    jgen.Initialize(map)
    Dim n As NB6
    mano = LoadBitmapResize(File.DirAssets, "mano.png", 24dip, 24dip, False)
    n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(mano)
    n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), jgen.ToString, Main).Notify(4)

End Sub



B4X:
Sub Activity_Resume
    Dim in As Intent = Activity.GetStartingIntent
    If in.IsInitialized And in <> OldIntent Then
        OldIntent = in
        Dim intentExtra As String
        If in.HasExtra("Notification_Tag") Then
            intentExtra = in.GetExtra("Notification_Tag")
            
            Log("XTRA="&intentExtra)
            Log("in="&in)
            Log("in ExtrasToString="&in.ExtrasToString)
            
            Dim jp As JSONParser
            jp.Initialize(intentExtra)
            Dim root As Map = jp.NextObject
            Label4.Text = root.Get("title")
            Label3.Text = root.Get("body")
            
        End If
    End If
End Sub

thank you
 

Isac

Active Member
Licensed User
Longtime User
Upvote 0

Isac

Active Member
Licensed User
Longtime User
I do not understand what blocks the message, maybe I have to give some permission to the smartphone?



** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
** Receiver (firebasemessaging) OnReceive **
** Service (firebasemessaging) Start **
Message arrived
Message data: ID 0:1531917950365614%959093b8959293b7, Data {}
Message=(RemoteMessage) com.google.firebase.messaging.RemoteMessage@b26a712
map=(MyMap) {title=Test1, body=Test2}
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
XTRA={"title":"Test1","body":"Test2"}
in=(Intent) Intent { flg=0x10020000 cmp=com.mio.read/.main (has extras) }
in ExtrasToString=Bundle[{Notification_Tag={"title":"Test1","body":"Test2"}}]
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
I don't see the "message arrived" line in the logs you posted while your app is in the background.


I showed in the video that the message arrives
but when I press the message this is not captured in the label (Activity_Resume).
In Data {} I should see the message but I do not see it.

Message data: ID 0:1531917950365614%959093b8959293b7, Data {}

thank you

 
Last edited:
Upvote 0
Top