Android Question exception of the incoming message

Isac

Active Member
Licensed User
Hello

When I receive the message, an exception is generated.

precisely this:

B4X:
firebasemessaging_fm_messagearrived (java line: 156)
java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=0 contentView=null vibrate=default sound=default defaults=0x7 flags=0x11 color=0x00000000 vis=PRIVATE)


I think the problem is here, but I do not know how to fix it, do you have any idea?
B4X:
    Dim map As Map
    map.Initialize
    map.Put("title","title")
    map.Put("body","body")



////////////////////////////////////////////////////////

LOG

** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Receiver (firebasemessaging) OnReceive **
** Service (firebasemessaging) Start **
Message arrived
Message data: ID 0:1531664675242804%959093b8959093b8, Data {}
firebasemessaging_fm_messagearrived (java line: 156)
java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=0 contentView=null vibrate=default sound=default defaults=0x7 flags=0x11 color=0x00000000 vis=PRIVATE)
at android.app.NotificationManager.notifyAsUser(NotificationManager.java:318)
at android.app.NotificationManager.notify(NotificationManager.java:293)
at android.app.NotificationManager.notify(NotificationManager.java:277)
at anywheresoftware.b4a.objects.NotificationWrapper.Notify(NotificationWrapper.java:281)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at anywheresoftware.b4a.BA$1.run(BA.java:330)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ID ${Message.MessageId}, Data ${Message.GetData}"$)
    Dim map As Map
    map.Initialize
    map.Put("title","title")
    map.Put("body","body")
    Dim jgen As JSONGenerator
    jgen.Initialize(map)
    Dim n As NB6
n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True)
n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), jgen.ToString, Main).Notify(4)
End Sub
 

DonManfred

Expert
Licensed User
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
The answer was right there in the second line down all along. Learning to read the logs is extremely important to debugging. I'm surprised that Manfred answered the question for you as I had already given you the biggest hint for you to learn from, all you had to do was check other notification code on the forum.

Anyway congratulation and hopefully you will now find it slightly easier to debug your code using the logs. Admittedly some error logs are not easy to decipher, but yours was extremely simple as the error was written in plain English for you at the top of the error message ;)
 
Last edited:
Upvote 0
Top