Android Question Firebase Notification Displays Icon from fm_MessageArrived when in Background

Status
Not open for further replies.

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using Firebase notifications in my app.

I have noticed that if I run the app in the background (running the app and then press the home button, so the app is not showing) if a notification is received it shows the name of my app in the title and message of the notification.

I also can't clear that notification after it has been received until the app fully closes.

Anyone else noticed this or know how to make it so that it doesn't display that notification?

In my fm_MessageArrived sub I have:

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
End Sub

There is no where in my app that makes it show the notification, so it looks like somehow the firebase lib is doing it ?

This only displays this notification when it receives a firebase message and the app is not visible on the screen. If the app is showing on the screen and a message is received then it doesn't show this notification.

This happens in both debug and release mode.

I am using B4A 8.00.
Running my App on Android 8.1.0
Target SDK 26.
FirebaseNotification Lib v1.10
FirebaseAnalytics Lib v1.00
 

aaronk

Well-Known Member
Licensed User
Longtime User
I missed that.

I used the following:

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    
    Sleep(0) 'allow the MessageReceived event to be raised.
    Service.StopAutomaticForeground
    
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
End Sub

It now no longer displays that notification which is good.

Is the above the correct way in doing it or should the Sleep(0), StopAutomaticForeground part be at the end of that sub like the following:

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    
    Sleep(0) 'allow the MessageReceived event to be raised.
    Service.StopAutomaticForeground
    
End Sub

I am guessing it should be as per the first block of code ?

What happens if the user reboots the phone and a firebase notification is sent. Will it start that service and show the notification or will it only display again when the user opens the app after the reboot ?
 
Upvote 0

softmicro

Member
Licensed User
Longtime User
I have the following problem.

I have received a notification from an arduino wifi module and I can not understand how to recover the data received individually to determine title and body

Sub fm_MessageArrived (Message As RemoteMessage) in Firebasemessaging application.


upload_2019-1-22_16-27-51.png


In this case items 11 (Titulo del evento) and 17 (DETECCION SENSOR)

I would appreciate very much if you can help me.
 

Attachments

  • upload_2019-1-22_16-24-9.png
    upload_2019-1-22_16-24-9.png
    23.4 KB · Views: 220
Upvote 0
Status
Not open for further replies.
Top