Android Question [SOLVED] Firebase Notifications no token returned

Num3

Active Member
Licensed User
Longtime User
[UPDATE 1] - Only SAMSUNG Phones seem affected Post #4
[SOLVED] - Firewall blocking part of google services network

Hello all,

I have a running project for some years now, and have migrated the php backend notification server to FCM v1, and is working like a charm.
All existing clients get notified as expected (at least until a token refresh is necessary).

Here is the situation:

If I install the old apk, or compile a new apk, the devices never get a token back from FCM, and because of that the notifications are broken.

I just installed the running version of my software on a clean factory reseted android phone (android 11), and it never gets a token back. Also, the example from "Firebase Push Notifications 2023+", using my software google-services.json does not work and the same thing happens: No token is returned.

I also created a new project on firebase console, exported the necessary keys, compiled the "Firebase Push Notifications 2023+" and no token is ever returned.

Could it be a problem with google shutting down the legacy API or a problem with the FirebaseNotification library?

I even disabled my firewall just in case, but nothing works.

This is driving me crazy!
 
Last edited:

Num3

Active Member
Licensed User
Longtime User
Create a new Firebase project and carefully follow the tutorial. Start with the updated B4J sending tool.

Well, for the sake of this reply.

New windows 11 VM + B4A + B4J install using OpenJDK 14 + OpenJFX 14 + Android SDK Command line tools + required resources + b4j-push-deps.zip
Same factory resetted android 11 phone (irrelavant, does not work on any phone tested)

Started a 3rd new firebase project with package name: b4a.test.fcm.

Exported the google-services.json and placed it in the B4A "Firebase Push Notifications 2023+" example directory. Then proceded to download the "Service Account" json file and placed it in the B4J working directory of the B4J-Sending tool.

Running the sending tool works (has does my php code):


Running the B4A example (with the correct package name to match the firebase project), again no token is ever received:


The B4A code for the firebasemessaging:

B4X:
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")
        Log($"[firebase | $Time{DateTime.Now}] Initialized -> ${fm.IsInitialized}"$)
    End If
    fm.HandleIntent(StartingIntent)
    Log($"[firebase | $Time{DateTime.Now}] ${StartingIntent}"$)
    Log($"[firebase | $Time{DateTime.Now}] token -> ${fm.Token}"$)
End Sub

Public Sub SubscribeToTopics (Topics() As Object)
    For Each topic As String In Topics
        fm.SubscribeToTopic(topic)
        Log($"[firebase | $Time{DateTime.Now}] subscribed -> ${topic}"$)
    Next
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log($"[firebase | $Time{DateTime.Now}] Message arrived"$)
    Log($"[firebase | $Time{DateTime.Now}] Message data: ${Message.GetData}"$)
    If B4XPages.IsInitialized And B4XPages.GetManager.IsForeground Then
        Log("App is in the foreground. In iOS a notification will not appear while the app is in the foreground (unless UserNotificationCenter is used).")
    End If
    Dim n2 As Notification
    n2.Initialize2(n2.IMPORTANCE_HIGH)
    n2.Icon = "icon"
    n2.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    n2.Notify(1)
End Sub

Sub fm_TokenRefresh (Token As String)
    Log($"[firebase | $Time{DateTime.Now}] Token -> ${Token}"$)
End Sub
 
Last edited:
Upvote 0

Num3

Active Member
Licensed User
Longtime User
[UPDATE]

I have narrowed the problem to SAMSUNG brand mobile phones, other brands i have tested do not show this problem.

At least the SM-A307FN and the SM-A346E models are affected.
 
Upvote 0

Num3

Active Member
Licensed User
Longtime User
Well finally getting somewhere:

"Failed to get FIS auth token" and some sqlite error "UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_i"

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…