Android Question Notification Issue

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using Firebase notifications in my app, and I have it displaying the notifications etc, but the icon doesn't seem to show.

I had the same issue once before but I wasn't using firebase etc: https://www.b4x.com/android/forum/threads/notification-icon.82779/#content

Code I am using is:

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    Dim n As Notification
    n.Initialize

    n.OnGoingEvent = False
    n.Sound = True
    n.Vibrate = True
    n.Icon = "icon"
    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    n.Notify(Rnd(1,999999))
End Sub

I noticed that the following tutorial says "If you are using B4A v8.0+ then the standard notifications will work."
https://www.b4x.com/android/forum/threads/version-safe-notification.87663/

What I have done in my code above, is that what the standard notifications is, and should it work or have I done something wrong?

Is there a way to use a custom icon/image? (not the app icon)

I am using B4A 8.00.
Running my App on Android 8.1.0
Target SDK 26.
 

aaronk

Well-Known Member
Licensed User
Longtime User
You can change the icon but lets first solve the notification issue.
I think you might of missed read my post. I have it displaying the notification (firebase notification is displaying) but it doesn't show the icon on the notification.

Are you sending the message with B4J?
Yes.

Are you running your app in release mode?
Yes, also tried in debug mode. (same result)

Are you avoid killing it with a swipe?
I am guessing you mean in the recent list. If so, no.

Are there any messages in the logs?
Only the info I log. No error messages.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
As a test, delete your own icon and let B4A set the default icon. Is it still missing?
I deleted: Objects\res\drawable\icon.png

I then clicked 'Tools' > 'Clean Project' and complied the app again.

Now the B4A default icon displayed for both my app icon and the icon in the notification.

I then selected my icon which is a png file (512x512 image), then cleaned projected again. My app icon is the correct icon again, but the notification icon is blank again.

I then checked the default one that b4A uses and it's a 128x128 png image. I then re-sized my icon to be 128x128 and I got the same result. App icon is fine but the notification icon is blank.

I then created a new image (512x512) made it so that the image has a round circle.

I then copied the image to Objects\res\drawable and named the image to 'notificationicon.png' and made it a readonly image.

In my code I changed n.Icon = "icon" to n.Icon = "notificationicon"

When I run my app, I am getting my normal app icon, which is what I want. Then when the notification comes through the icon is a round circle. For some reason the icon is not in colour. I guess my original app icon would of worked (or is working) except since it is showing as one colour then it making it look like it's blank (all grey). My test app showed my notification icon in colour though.
 
Upvote 0
Top