Android Question Firebase Push Notifications not received until uninstall -> reinstall app

hazaal

Member
Licensed User
Longtime User
Hi,

I just implemented [B4X] Firebase Push Notifications 2023+ last week, and it’s usually working nicely. I haven’t published these new features yet, but during development, it has now happened twice that push notifications suddenly stop being received, and I cannot figure out why. Nothing helps, not even the example project (PushClient in the link above) works. Until I uninstall my app. After reinstalling, without any changes to code, push notifications are received again perfectly.

In Google's Firebase Cloud Messaging API console I can see that some data is moving, but not been received.

I am using Topics, so it cannot be a Token-related issue.

The code is more or less the same as in the example project.

B4XMainPage:
CallSubDelayed2(FirebaseMessaging, "SubscribeToTopics", Array("general", "did" & dID))

FirebaseMessaging:
Sub Process_Globals
    Private fm As FirebaseMessaging
End Sub

Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    If FirstTime Then
        fm.Initialize("fm")
    End If
    fm.HandleIntent(StartingIntent)
End Sub

Public Sub SubscribeToTopics (Topics() As Object)
    Log("SubscribeToTopics...")
    For Each topic As String In Topics   
        fm.SubscribeToTopic(topic)
        Log("Subscribed to: " & topic)
    Next   
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Dim mpn_data As String
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    
    Dim body As String = Message.GetData.Get("body")
    Dim title As String = Message.GetData.Get("title")
    
    If title = "deliveries" Then
        If kuvattavat_toimitukset.IsInitialized = False Then
            kuvattavat_toimitukset.Initialize
            If File.Exists(File.DirInternal, "Deliveries.txt") Then
                kuvattavat_toimitukset = File.ReadMap(File.DirInternal, "Deliveries.txt")
            End If
        End If

        Dim itemStrings() As String = Regex.Split("\|", body)
        For Each itemString As String In itemStrings
            Dim itemData() As String = Regex.Split(",", itemString)
            Dim key As String = itemData(0)
            Dim value As String = itemData(1) & "," & itemData(2)
            kuvattavat_toimitukset.Put(key, value)
        Next   

        File.WriteMap(File.DirInternal, "Deliveries.txt",kuvattavat_toimitukset)
    Else   
        Dim n2 As Notification
        n2.Initialize2(n2.IMPORTANCE_HIGH)
        n2.Icon = "icon"
        n2.SetInfo(title, body, Main)
        n2.Notify(1)
    End If
End Sub


FCMPush in B4J is the very same as in Erel's b4j-sendingtool-zip, I can post is if you wish, but there is not much (new) code to see...
 

asales

Expert
Licensed User
Longtime User
Which device and Android version?
I have a similar problem with Redmi 9A (Android 10) and the emulator (14), but the notifications works in a Samsung A71 (13) and Redmi 8A (10).
 
Upvote 0

hazaal

Member
Licensed User
Longtime User
Thanks, but yes, all of those have been done.

I think I’ll try with a "better" phone, but I guess it’s not a real fix—we have over 50 inexpensive phones being used as PDAs, plus some actual PDA devices, and I’m not willing to replace those A14s with devices costing 500-700€.
 
Upvote 0

fbritop

Well-Known Member
Licensed User
Longtime User
Thanks, but yes, all of those have been done.

I think I’ll try with a "better" phone, but I guess it’s not a real fix—we have over 50 inexpensive phones being used as PDAs, plus some actual PDA devices, and I’m not willing to replace those A14s with devices costing 500-700€.
I had the same problem, happens only in Android with topics in my case. My deivce was an Redmi Note 13, which is not an "old" phone I think

 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
Hi,

I just implemented [B4X] Firebase Push Notifications 2023+ last week, and it’s usually working nicely. I haven’t published these new features yet, but during development, it has now happened twice that push notifications suddenly stop being received, and I cannot figure out why. Nothing helps, not even the example project (PushClient in the link above) works. Until I uninstall my app. After reinstalling, without any changes to code, push notifications are received again perfectly.

See this.... it may help explain your issue:

 
Upvote 0

fbritop

Well-Known Member
Licensed User
Longtime User
See this.... it may help explain your issue:

I think the issue was something about FireBase endpoint.
Since 6 days ago with no changes on my push server, which runs under the google SDK, no changes on any library on B4A, there has been no more interruptions. As I stated before, I think this has something to do with google. There was just an issue reported regarding FBM with iOS on FireBase status. As no changes has been made no anything external to FireBase, I think this was something to do with firebase. I also noticed that this was just related to topics in Android, none of this happend to tokens (on both OS), and to topics in iOS.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
I recently just had 2 customers with a similar issue.

If the customer unsubscribes from the topic and then subscribes again it doesn't fix the issue. They had to uninstall the app and then reinstall it again, then subscribe to the topic again.

I am not sending it to the token but using topics.

One of the customers said other apps on his device also has a similar issue.

Looking at the firebase status page it shows there is a known issue at the moment.

 
Upvote 0
Top