firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
819 stars 424 forks source link

Subscribing/Unsubscribing to topics doesn't work on Android #1294

Closed AOEGame closed 1 year ago

AOEGame commented 1 year ago

[READ] For Firebase Unity SDK issues, please report to Firebase Unity open-source

Once you've read this section and determined that your issue is appropriate for this repository, please delete this section.

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

        Firebase.Messaging.FirebaseMessaging.UnsubscribeAsync(topic).ContinueWith(task =>
        {
            Debug.Log("FirebaseMessaging.UnsubscribeAsync:" + topic + " status:" + task.Status);

        });

I can not get the debug.log. also test: awit Firebase.Messaging.FirebaseMessaging.UnsubscribeAsync

android version: 9

Relevant Code:

Firebase.FirebaseApp.LogLevel = Firebase.LogLevel.Verbose; Firebase.Messaging.FirebaseMessaging.TokenRegistrationOnInitEnabled = true; Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);

            Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
            Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
            string topic = "Lan_en";

        Firebase.Messaging.FirebaseMessaging.UnsubscribeAsync(topic).ContinueWith(task =>
        {
            Debug.Log("FirebaseMessaging.UnsubscribeAsync:" + topic + " status:" + task.Status);

        });
AOEGame commented 1 year ago

anyone?

paulinon commented 1 year ago

Hi @AOEGame,

Thanks for reporting this issue. While I try to replicate this, could you verify if the behavior persists using version 9.2.0 of the SDK? Are you getting any error messages after performing this operation?

AOEGame commented 1 year ago

Hi @AOEGame,

Thanks for reporting this issue. While I try to replicate this, could you verify if the behavior persists using version 9.2.0 of the SDK? Are you getting any error messages after performing this operation?

After a lot of testing, I found out that the first launch then subscribe topic is successful. After restart our game then subscribe topic, the subscribeAsync task can not finish.

no error message.

the subscribeAsync task does not have any completion information.

Had set LogLevel: Firebase.FirebaseApp.LogLevel = Firebase.LogLevel.Debug;

but no error message in android studio logcat!

AOEGame commented 1 year ago

Hi @AOEGame,

Thanks for reporting this issue. While I try to replicate this, could you verify if the behavior persists using version 9.2.0 of the SDK? Are you getting any error messages after performing this operation?

9.2.0 has the same problem.

first launch then subscribe topic is successful. kill app then restart, subscribeAsync task can not finish.

AOEGame commented 1 year ago

same problem like this: https://stackoverflow.com/questions/68642761/unity-firebase-subscribe-unsubscribe-from-topic-issue-on-reloading-app

AOEGame commented 1 year ago

please help me!

AOEGame commented 1 year ago

@paulinon any update?

paulinon commented 1 year ago

Hi @AOEGame,

I was able to replicate this behavior on my end, and it appears to be related to this bug where OnTokenReceived is called only on fresh app installs. The team is still working on the fix, and while you can refer to the aformentioned thread for updates, you may delete the token and get a new one as a workaround.