quickstart-unity
quickstart-unity copied to clipboard
Android Firebase 8.0.0 TokenReceived called only on application reinstall
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2018.4.31f1
- Firebase Unity SDK version: 8.0.0
- Source you installed the SDK: .unitypackage
- Problematic Firebase Component: Messaging
- Other Firebase Components in use: Analytics
- Additional SDKs you are using: Google Play, Adjust, Appmetrica, DevToDev, Ironsource ad mediation( mediation networks Ironsource, UnityAds, Admob, Facebook, AdColony)
- Platform you are using the Unity editor on: Mac 11.4
- Platform you are targeting: iOS, Android
- Scripting Runtime: IL2CPP
[REQUIRED] Please describe the question here:
After updating the Firebase Unity SDK from version 7.1.0 to version 8.0.0, the TokenReceived event on android stopped being called after each initialization. Now now the event comes only once when installing the application. On iOS, everything is still correct. A direct call to FirebaseMessaging.GetTokenAsync returns the push token correctly.
Is this a bug or a new behavior and now we need to get a token like in android sdk and save it until the next change?
=======================================================================================
Dependencies:
com.adcolony:sdk:4.5.0
com.android.installreferrer:installreferrer:2.1
com.android.support:support-compat:26.1.0
com.android.support:support-v4:26.1.0
com.facebook.android:audience-network-sdk:6.5.0
com.google.android.gms:play-services-ads:20.1.0
com.google.android.gms:play-services-ads-identifier:17.0.0
com.google.android.gms:play-services-base:17.6.0
com.google.android.gms:play-services-basement:17.5.0
com.google.firebase:firebase-analytics:19.0.0
com.google.firebase:firebase-analytics-unity:8.0.0
com.google.firebase:firebase-app-unity:8.0.0
com.google.firebase:firebase-common:20.0.0
com.google.firebase:firebase-messaging:22.0.0
com.google.firebase:firebase-messaging-unity:8.0.0
com.google.games:gpgs-plugin-support:0.10.12
com.ironsource.adapters:adcolonyadapter:4.3.8
com.ironsource.adapters:admobadapter:4.3.20
com.ironsource.adapters:facebookadapter:4.3.27
com.ironsource.adapters:unityadsadapter:4.3.11
com.ironsource.sdk:mediationsdk:7.1.6
com.tapjoy:tapjoy-android-unitybridge:12.8.1
com.unity3d.ads:unity-ads:3.7.2
We are using manual initialization.
Android manifest:
<service android: name = "com.google.firebase.messaging.MessageForwardingService" android: permission = "android.permission.BIND_JOB_SERVICE" android: exported = "false" />
<meta-data android: name = "firebase_messaging_auto_init_enabled" android: value = "false" />
<meta-data android: name = "firebase_analytics_collection_enabled" android: value = "false" />
Our initialization code:
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
{
DependencyStatus dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available)
{
m_firebaseInstance = FirebaseApp.DefaultInstance;
if (PluginManager.Instance.IsAllowRequestNotificationsPermission)
{
FirebaseMessaging.TokenReceived += OnTokenReceived;
FirebaseMessaging.MessageReceived += OnMessageReceived;
FirebaseMessaging.TokenRegistrationOnInitEnabled = true;
}
}
else
{
// ...
}
});
=======================================================================================
Hi @maniaks1,
In order to identify what's causing this behavior, could you provide a minimal, reproducible example of your project along with the complete steps taken before facing the issue?
Hi @paulinon!
This behavior is repeated in the test firebase project. Steps to repeat:
- Download test project
- Add analytics and messaging from firebase sdk 8.0.0 (dotnet 4).
- Add ExternalDependencyManager 1.2.166.
- Run Android Resolver -> Force resolve.
- Add google-services.json
As a result, the PushToken comes only on first launch. P.S. I don't know whether it is important or not, but all actions were performed on a debug unsigned build, but on the old version of the SDK everything was fine.
I think this also prevents us from subscribing, unsubscribing to/from topics. Reverting back to 7.2.0 seems to fix this problem.
@maniaks1
Thanks for reporting. I think I can reproduce the issue with the following steps.
- Build the testapp with Firebase SDK
8.1.0
and install it to a device - Observe the log like
Received Registration Token
,RequestPermissionAsyn completed
andSubscribeAsync completed
. - Click on
Subscribe
button and observe it complete successfully. - Kill the app using system tray and relaunch the app.
- Observe no log like
Received Registration Token
orSubscribeAsync completed
- Click on
Subscribe
button. Observe that the async call never complete.
It does not seem to be related to firebase_messaging_auto_init_enabled
.
Also I can confirm that 7.2.0
does not have this issue.
Firebase FCM Unity SDK 8.1.0
depends on the following Android libraries
implementation 'com.google.android.gms:play-services-base:17.6.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.firebase:firebase-analytics:19.0.0' // Assets/Firebase/Editor/MessagingDependencies.xml:15
implementation 'com.google.firebase:firebase-app-unity:8.1.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-common:20.0.0' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging:22.0.0' // Assets/Firebase/Editor/MessagingDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging-unity:8.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:20
Firebase FCM Unity SDK 7.2.0
depends on the following Android libraries:
implementation 'com.google.android.gms:play-services-base:17.6.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.firebase:firebase-analytics:18.0.3' // Assets/Firebase/Editor/MessagingDependencies.xml:15
implementation 'com.google.firebase:firebase-app-unity:7.2.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-common:19.5.0' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging:21.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging-unity:7.2.0' // Assets/Firebase/Editor/MessagingDependencies.xml:20
As a workaround, you will have to uninstall the Firebase 8.x
and install 7.2.0
This also may related to the Android S FCM rework mentioned in b/184368806.
Another workaround is to delete the token and get a new one. The reception of the new token also triggers all previous attempts to subscribe/unsubscribe to/from a topic, so it seems everything is still queued and only proceeds once a token arrives. During an app session where a token arrived, subscribing/ unsubscribing works as intended. After killing and restarting the app, subscribing/ unsubscribing is not working anymore.
Behavior can be reproduced with sample scene.
- Clean install a new app
- Subscribing / unsubscribing works as intended
- Kill app and restart
- Subscribing / unsubscribing is not working anymore
- Delete token
- Get token
- All previous attempts to subscribe / unsubscribe are now processed (all subscribing events before unsubscribing though, no matter the initial order)
- Subscribing / unsubscribing works as intended again (until next app start)
Another workaround that works for us is to await FirebaseMessaging.GetTokenAsync() It gives the same token as the event on first install, then the same token next times when the event doesn't fire.
It seems that the changelog for 8.3.0 mention this was fixed, but it's still not working for us after updating the SDK.
Calling await FirebaseMessaging.GetTokenAsync()
still works as a workaround.
Hi! The same issue, TokenReceived is called only after the first app launch. The workaround is to use GetTokenAsync.
Firebase 8.1.0 / GPGS 0.10.12 Firebase 8.3.0 / GPGS 0.10.12
Another sad thing is that MessageReceived also doesn't work. I'll try downgrading to Firebase 7...
Another sad thing is that MessageReceived also doesn't work. I'll try downgrading to Firebase 7...
Try placing await GetTokenAsync() before Message received ?
Another sad thing is that MessageReceived also doesn't work. I'll try downgrading to Firebase 7...
Try placing await GetTokenAsync() before Message received ?
Looks like Firebase Test notification doesn't work, but MessageReceived works if I send notifications via HTTP API.
Fixed in release 8.3.0
@cynthiajoan Like I said above, this is NOT fixed in 8.3.0. Still happening with that version! You can see above that other people still have the issue with 8.3.0, too!
Yes, NOT fixed.
@paulinon @dconeybe Can someone please re-open or look into this?
Hi @Nyankoo,
So sorry to hear that the issue wasn't fixed in the latest release. The team is currently working on this.
@paulinon do you know when will this be fixed?
I just installed 8.6 and same problem as before.
Hi @injeniero, I don't have a timeline I can share, but the team is working on this.
Same problem on v8.6.2
Just spent 3 hours figuring out why topic notification is never received :) await FirebaseMessaging.GetTokenAsync() workaround does NOT work for me
v8.6.2 Unity
Yes , await FirebaseMessaging.GetTokenAsync() doesn't work for me neither. Still using 7.2.0 please fix this.
Any updates on a fix for this @paulinon ? if there's no fix planned, can you suggest a workaround we could implement?
Any news?
Any confirmation on whether this is fixed in 8.8.0? There's sadly no mention of it in the changelog
I have the same problem in 8.8.0
I confirm the issue in 8.8.0: receiving the token via the callback and subscribing to topics only work during the first launch of the app. In subsequent sessions even if I change the subscriptions when the player changes the language of the app SubscribeAsync
doesn't have any effect.
The await FirebaseMessaging.GetTokenAsync()
workaround works to get a token but doesn't change anything for the subscriptions issue.
Edit: are some of you using 7.2 in the meantime? I'd like to avoid going back to an old version but maybe it cannot be helped for now since there hasn't been any update for a while.
Anything new about this ? this is a critical bug for me and for others, the ability to subscribe to topics is a must.
Tested on 9.0 still the same problem, is there any workaround ?
Using 7.2 just for this is really messed up
@paulinon Any update?