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):

TOKEN -> ya29.c.c0AY_VpZimhEzTcW9OQ5UoE_Q9Yyf-4a3a2QSgPkraH4-yacg8qox2XfcIp5NNppbJPuafWVwH31E ....
{
"message": {
"data": {
"title": "this is the title",
"body": "And this is the body"
},
"android": {
"priority": "high"
},
"topic": "general"
}
}
{
"name": "projects/b4a-test-fcm/messages/7487145638742767716"
}
{
"message": {
"notification": {
"title": "this is the title",
"body": "And this is the body"
},
"data": {
"title": "this is the title",
"body": "And this is the body"
},
"topic": "ios_general",
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"badge": 0,
"sound": "default"
}
}
}
}
}
{
"name": "projects/b4a-test-fcm/messages/8060350948982333879"
}

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

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (firebasemessaging) Receive (first time) ***
[firebase | 13:12:08] Initialized -> true
[firebase | 13:12:08] Intent { flg=0x10 cmp=b4a.test.fcm/.firebasemessaging }
[firebase | 13:12:08] token ->
[firebase | 13:12:08] subscribed -> general

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"

IndexChimeraService.getServiceInterface callingPackage=com.google.android.gms componentName=AppsCorpus serviceId=36
Class com.google.firebase.auth.FirebaseAuthRegistrar is not an found.
Class com.google.firebase.abt.component.AbtRegistrar is not an found.
Class com.google.firebase.iid.Registrar is not an found.
Class com.google.firebase.firestore.FirestoreRegistrar is not an found.
Class com.google.firebase.database.DatabaseRegistrar is not an found.
Class com.google.firebase.remoteconfig.RemoteConfigRegistrar is not an found.
Class com.google.firebase.storage.StorageRegistrar is not an found.
Class com.google.firebase.crashlytics.CrashlyticsRegistrar is not an found.
Compat change id reported: 183155436; UID 10396; state: ENABLED
Device unlocked: initializing all Firebase APIs for app [DEFAULT]
Failed to get FIS auth token
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks@@18.0.2:5)
at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks@@18.0.2:8)
at com.google.firebase.messaging.GmsRpc.setDefaultAttributesToBundle(GmsRpc.java:260)
at com.google.firebase.messaging.GmsRpc.startRpc(GmsRpc.java:222)
at com.google.firebase.messaging.GmsRpc.getToken(GmsRpc.java:180)
at com.google.firebase.messaging.FirebaseMessaging.lambda$blockingGetToken$10$com-google-firebase-messaging-FirebaseMessaging(FirebaseMessaging.java:610)
at com.google.firebase.messaging.FirebaseMessaging$$ExternalSyntheticLambda7.start(Unknown Source:6)
at com.google.firebase.messaging.RequestDeduplicator.getOrStartGetTokenRequest(RequestDeduplicator.java:67)
at com.google.firebase.messaging.FirebaseMessaging.blockingGetToken(FirebaseMessaging.java:606)
at com.google.firebase.messaging.FirebaseMessaging.lambda$getToken$4$com-google-firebase-messaging-FirebaseMessaging(FirebaseMessaging.java:392)
at com.google.firebase.messaging.FirebaseMessaging$$ExternalSyntheticLambda10.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)
at java.lang.Thread.run(Thread.java:923)
Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:208)
at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:536)
at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:390)
at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$3$com-google-firebase-installations-FirebaseInstallations(FirebaseInstallations.java:375)
at com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda0.run(Unknown Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
... 1 more
Error inserting flex_time=5000 job_id=-1 period=12000 source=16 requires_charging=0 preferred_network_type=1 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 required_idleness_state=0 service_kind=0 source_version=242213000 persistence_level=1 preferred_charging_state=1 required_network_type=0 runtime=1719253623000 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} last_runtime=0 [CONTEXT service_id=218 ]
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE[2067])
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:1217)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:2219)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:2114)
at clwr.d:)com.google.android.gms@242213031@24.22.13 (150400-638740827):737)
at clue.n:)com.google.android.gms@242213031@24.22.13 (150400-638740827):29)
at clue.u:)com.google.android.gms@242213031@24.22.13 (150400-638740827):360)
at clue.h:)com.google.android.gms@242213031@24.22.13 (150400-638740827):51)
at cloz.run:)com.google.android.gms@242213031@24.22.13 (150400-638740827):72)
at amio.c:)com.google.android.gms@242213031@24.22.13 (150400-638740827):50)
at amio.run:)com.google.android.gms@242213031@24.22.13 (150400-638740827):76)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at amoe.run:)com.google.android.gms@242213031@24.22.13 (150400-638740827):8)
at java.lang.Thread.run(Thread.java:923)
 
Upvote 0
Top