Android Question Push Notification (Firebase) Not showing on some smartphones

Mike1970

Well-Known Member
Licensed User
Hi everyone, i recently distributed an app that includes push notification.
the notifications are locally created with the NB6 class.

Unfortunately i‘ve got some feedbacks from my user saying that they are not receiving the notifications.

I asked them what phone they are using:
90% Huawei, and some Samsung..
I know about the problem with Huawei, the Battery Optimization thing (very annoying)... but samsung?

My temporary solution is to set the “notification” tag in the payload sent via Firebase, I didn’t tried yet, but I think this could solve some of this problems since in this way the notification is managed by the OS... but I’ve to renounce to the “BigText” notification I was using with the NB6 class.

Have you some tips?

thanks guys
 

Mike1970

Well-Known Member
Licensed User
2. Can you post the notification service code?
B4X:
Sub Process_Globals
    Private fm As FirebaseMessaging
    Private notification As NB6
    Private tmpTopic As String
End Sub

Sub Service_Create
    fm.Initialize("fm")
End Sub

Public Sub SubscribeToTopics
'    fm.SubscribeToTopic("SPN") 'you can subscribe to more topics
'  
    fm.UnsubscribeFromTopic("ios_SPN_TEST")
    fm.UnsubscribeFromTopic("ios_SPN")
    fm.UnsubscribeFromTopic("SPN_TEST")
    fm.UnsubscribeFromTopic("SPN")
'  
    Dim r As ResultSet = Starter.FileManager1.SQL1.ExecQuery("SELECT NomeClasse FROM classi")
    Do While r.NextRow
        tmpTopic = r.GetString("NomeClasse").Replace("°","").Replace(" ", "").Replace(".","").Replace("(","").Replace(")","").Replace("'","").Trim
        fm.UnsubscribeFromTopic(tmpTopic)
    Loop
   
    tmpTopic = Starter.FileManager1.LeggiValore("Classe")
    If tmpTopic <> "" Then
        tmpTopic = tmpTopic.Replace("°","").Replace(" ", "").Replace(".","").Replace("(","").Replace(")","").Replace("'","").Trim
        Log("SottoScritto a: " & tmpTopic)
        fm.SubscribeToTopic(tmpTopic)
    End If
End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    Sleep(0)
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
   
    If Not(IsPaused(Home)) Then
        CallSub(Home, "SincronizzaDBInterno")
    End If

    notification.Initialize("default", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(Application.Icon)
    notification.BigTextStyle(Message.GetData.Get("titolo"), Message.GetData.Get("summary"), Message.GetData.Get("corpo"))
    Dim n As Int = Starter.FileManager1.LeggiValore("IdNotifica")
    n = n + 1
    notification.Build(Message.GetData.Get("titolo"), Message.GetData.Get("corpo"), "", Home).Notify(n)
    Starter.FileManager1.AggiornaFile("IdNotifica", n)
End Sub

Sub Service_Destroy

End Sub



3. I don't think that adding the notification tag will change anything. Better to remove it.
I tested it, and it doesn't work (in my Meizu, i had to go to "Security">"Authorization">"background" and set "permit continuos bakground"), but... this is a problem for an user that has a Meizu, Xiaomi, and all the brands that apply this limitation..


4. Are you sending the messages with the B4J code?
I use it only for testing, but when the service have to run normally, the notification are sent from my server via http post (the payload i sent is the same i send with B4J)
 
Last edited:
Upvote 0

Mike1970

Well-Known Member
Licensed User
On this website i founded this thing to workaround huawei system.

Cattura.PNG

Link to this page: https://dontkillmyapp.com/huawei

But i really don't know how to translate this code to B4A...
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
This is not relevant. Push notifications, when configured properly, arrive even when the app is not running.

I configured them like you did in your tutorial, i used the B4J Tool to send a notification to my Meizu (affected by the problem), and it didn't arrive with the app not running.
So... knowing that Huawei has the same issue, a good percentage of andoird users is not receving my push notifications?
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Might be related to this: http://forum.flymeos.com/thread-22736-1-1.html
Push messages will not work if Google Play Services can't run in the background.

Yes, from that section before i allowed my specific app. not the google play services and it worked anyway.
Unfortunately i know that Huawei has the same issue, but it have to be solved in another way, and so on for all the different OEM's that blocks the push notifications from not-verified apps.
Everyone have to solve it manually for his phone (if has the problem), its very annoying that Android is so cutomizable...

From your previous answers i understand that there is no "code way" to solve the problem for everyone right?
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Not really.

The solution app will help your app run all the time. This is not what you want and I'm sure that it will fail on many devices. It is relevant for tasks such as the "background location tracking" example.

The app i've done is already on the PlayStore , so i could not use this method.
It is suitable for Industry Application.

I only hope that there are not so many devices with this problem :confused:
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
It is also important to provide another way for your app to retrieve the information when it opens. Don't rely on notifications.
My app is a "Google Drive notifier", when it opens up shows a list of files contained in a private directory.
when someone adds a file to that directory all the people interested in it receive a notifcation.

But actually not all the people at this point 😂.
(since the file list is saved on a database, when the app opens obviously refresh the list accordingly, but the main function for the user was the notification system :confused:)
 
Upvote 0
Top