-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Firebase 8.0.0 TokenReceived called only on application reinstall #1088
Comments
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.
As a result, the PushToken comes only on first launch. |
I think this also prevents us from subscribing, unsubscribing to/from topics. |
Thanks for reporting. I think I can reproduce the issue with the following steps.
It does not seem to be related to Also I can confirm that Firebase FCM Unity SDK
Firebase FCM Unity SDK
As a workaround, you will have to uninstall the Firebase |
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. Behavior can be reproduced with sample scene.
|
Another workaround that works for us is to await FirebaseMessaging.GetTokenAsync() |
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. |
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! |
I literally almost when crazy before finding the problem, but it also happens to me. Unity 2021.3 and Firebase 9.0.0. I assume this ain't fixed (which literally makes FCM for Unity useless, like??), is there any reliable workaround for subscribing/unsubscribing to topics and recieving messages/notifications? (other than downgrading to 7.2, which I really want to avoid). Thank you. |
Long ago (like 3-4 years), when upgrading Scripting Backend or Api Compatibility Level in Unity (when they changed the .NET to 4.x if I remember correctly), I had a similar issue: suddently, some functions were not working: not showing in the logs, even with Logcat, even though I added manual "Debug.Log" before & inside it to prove it was being correctly called, and found out it was not working because it was not being called in the main thread. In the Firebase Documentation the following is specified under the function "[System.Threading.Tasks.Task] SubscribeAsync" & others: "Call this function from the main thread. FCM is not thread safe.". Maybe what's happening is that, for whatever reason, it is not being called in the main thread. Does that makes sense? Anyways, could it be possible to force it be called in the main thread? Thank you. |
same problem in 9.1.0 and 9.2.0 |
anyone fixed this problem?? any workaround? |
do you find any workarounds? this is a critical bug for me |
@Guidanel do you find any workarounds? |
The workaround is to use version 7.2.0 |
Thank you very much for your answer! I use : Analytics,Crashlytics, Messaging |
I'm not sure if it'll let you mix versions without issues, but you can try it and see what happens I guess |
The workaround I posted last August is still working as well: FirebaseMessaging.DeleteTokenAsync().ContinueWithOnMainThread( task1 => |
I can confirm this issue is still present in 9.0.0, and it has now persisted for more than a year since 7.2.0 Also, the release notes for Version 8.2.0 still INCORRECTLY STATE that the Android issue of receiving tokens when initializing the app has been fixed The issue is that on Android, the TokenRecieved delegate is only fired on the initial install. It never fires any time the app is run after the initial install. The issue also makes it so the Subscribe and Unsubscribe calls do not work. This issue is not present on iOS The console log shows that the Subscribe or Unsubscribe task is called and just waits forever never receiving a response...and there is also incomplete information with above proposed workarounds I want to help with GetTokenAsync() - Not a workaround DeleteTokenAsync() and GetTokenAsync() - Not a workaround Workaround 1 - DeleteTokenAsync() and GetTokenAsync() and Re-subscribe Workaround 2 - Continue using Firebase 7.2.0 SDKs My question to Google Firebase Developers ..also, it might be helpful to put the workaround you suggest in the Unity Setup documentation or the Unity Troubleshooting notes, as the current notes have not led to a working solution for over a year, and seem to be causing hours and days of troubleshooting for developers until they stumble upon this |
Still a problem in version 9.4.0. I can confirm that workaround number 1 works for me, thank you @jmcgee412 ! As you say, not ideal as you need the client to keep a list of topics to re-suscribe ( and not to mention how slow I presume it is to do the whole process everytime ), but at least it works. |
Still an issue with 9.6.0. Wasted a few hours troubleshooting this mess. Going back to 7.2.0 since the other workaround is pretty unreasonable. |
@cynthiajoan is the firebase team aware this is still an issue or is it planned to be looked into again? 8.3.0 did not fix it as many others in this issue thread have mentioned :( |
Another workaround:
// instead of TokenReceived
FirebaseMessaging.GetTokenAsync().ContinueWith(() => {
// ...
});
// instead of SubscribeAsync()/UnsubscribeAsync() of Firebase Unity SDK
var firebaseWorkaround = new AndroidJavaClass("FirebaseMessagingWorkaround");
firebaseWorkaround.CallStatic("subscribeAsync", topicName);
firebaseWorkaround.CallStatic("unsubscribeAsync", topicName); Assets/Plugins/Android/FirebaseWorkaround.java import android.util.Log;
import androidx.annotation.NonNull;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.messaging.FirebaseMessaging;
public class FirebaseMessagingWorkaround
{
public static void subscribeAsync(String topic)
{
FirebaseMessaging.getInstance().subscribeToTopic(topic)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
String msg;
if (task.isSuccessful())
{
msg = topic + " Subscribed";
}
else
{
msg = topic + " Unsubscribe failed";
}
Log.d("FirebaseWorkaround", msg);
}
});
}
public static void unsubscribeAsync(String topic)
{
FirebaseMessaging.getInstance().unsubscribeFromTopic(topic)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
String msg;
if (task.isSuccessful())
{
msg = topic + " Unsubscribed";
}
else
{
msg = topic + " Unsubscribe failed";
}
Log.d("FirebaseWorkaround", msg);
}
});
}
} Of course, you can also call |
For anyone still looking: Don't bother updating yet, FCM v10.2.0 seems to have the same problem. |
Right, they don't want to fix it, so GetTokenAsync() is the only solution at the moment. |
FCM v10.3.0. |
Experiencing the same problem! Any news on that issue? It is super annoying that this still hasn't been fixed but is still the recommended way to do things in the docs. I would suggest to either fix this or update the docs. |
@paulinon Pinging you to get this some attention. This issue is almost 2 years old now! |
Is Firebase even maintained still? Just updated from my old 7.2 Firebase version to 10.7 to try some of the latest desktop support beta stuff, just to find that this crucial feature is broken since ages. That's ridiculous... |
This is still happening on 11.6.0 fb team all looking happy on youtube |
@paulinon @chkuang-g @cynthiajoan A statement would be nice. It's unbelievable that this is still not fixed! |
Still not working...? I can't wait to work it. |
Still problem on 11.9.0. |
So here we are again, almost two years since I last commented, SDK 12.1.0 and this is still an issue. To re-iterate, just calling GetTokenAsync() will not work, since it will only give you the token, the SDK is still broken and subscribing will NOT actually work. Good news though, I did try the workaround suggested by [homu-konamilk] #1088 (comment) Makes you wonder how many Unity Android Apps have broken firebase integrations out there when everything seems fine first launch. Anyway, hopefully someone finds this useful, try the aforementioned workaround. :) |
The latest release should finally fix this, 12.3.0, https://github.com/firebase/firebase-unity-sdk/releases/tag/v12.3.0 Thanks for raising this, and sorry it took so long to fix. |
[REQUIRED] Please fill in the following fields:
[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:
We are using manual initialization.
Android manifest:
Our initialization code:
=======================================================================================
The text was updated successfully, but these errors were encountered: