Skip to content

Subscribing/Unsubscribing to topics doesn't work on Android [Bug] #1098

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

Closed
OrionDev23 opened this issue Jul 21, 2021 · 8 comments
Closed

Subscribing/Unsubscribing to topics doesn't work on Android [Bug] #1098

OrionDev23 opened this issue Jul 21, 2021 · 8 comments

Comments

@OrionDev23
Copy link

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.14f
  • Firebase Unity SDK version: 8.1.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Cloud messaging
  • Other Firebase Components in use: Auth, Database, installations, storage,crashalytics,analytics
  • Additional SDKs you are using: Facebook,google sign in
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android (works on iOS)
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

When i try to subscribe to a topic, and wait for the operation to finish, it ends in endless loop as the operation doesn't seem to work, same thing when unsubscring, it was working using 7.2.

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? yes
What's the issue repro rate? 80% (only works for the first run (when the app is installed)

What happened? How can we make the problem occur?
Try subscribing / usubscring to a topic in a task and wait for the operation to finish then do something else

@OrionDev23
Copy link
Author

OrionDev23 commented Jul 21, 2021

it may be the same problem mentioned here

@ModischFabrications
Copy link

ModischFabrications commented Jul 21, 2021

Just encountered the same problem, which both prevents new notifications and prevents us from unregistering old ones.

The first log is always printed, the second one never.

        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
        {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                [...]
                Debug.Log($"Trying to subscribe to {Topic}...");
                FirebaseMessaging.SubscribeAsync(Topic).ContinueWithOnMainThread(t =>
                {
                    if (t.IsFaulted) throw t.Exception;
                    Debug.Log($"Firebase subscribed successfully");
                });
          [...]

Clearing all data from app settings seems to allow a singular SubscribeAsync, as do reinstalls.

Version 8.0.0, just using Messaging & Analytics

@paulinon paulinon removed the new New issue. label Jul 22, 2021
@paulinon
Copy link
Contributor

Hi @OrionDev23,

Thanks for reporting the issue. It's possible that this is related to #1088. In order to confirm this, could you provide a minimal, reproducible example of your project along with the steps you've taken before facing this behavior?

@paulinon paulinon added the needs-info Need information for the developer label Jul 22, 2021
@OrionDev23
Copy link
Author

OrionDev23 commented Jul 22, 2021

public IEnumerator<float> SubToThis()
    {
        followButtonButton.interactable = false;
        while (!fetchState) //waiting to check if already subbed or not
            yield return Timing.WaitForSeconds(0.1f); 
        if (subbed)  // if already subbed show sub button
        {
            bell.Play("Out"); 
            followButton.normalText.DOText("Follow", 0.3f).PlayForward();
            Task t = Task.WhenAll(ShopFetcher.instance.personalReference.Child("mysubs").Child(DatabaseTimeStamp.myEmail).Child(shopID).RemoveValueAsync(),
                ShopFetcher.instance.personalReference.Child("subscription").Child(shopID).Child(DatabaseTimeStamp.myEmail).RemoveValueAsync(),
                FirebaseMessaging.UnsubscribeAsync(string.Format("{0}{1}c", shopID, cle)), MinusFollow(shopID));
            while (!t.IsCompleted && !t.IsFaulted && !t.IsCanceled)
                yield return Timing.WaitForSeconds(0.1f);  //this is where it gets stuck, cause UsubscribeAsync won't return a state
            subbed = false;
        }
        else
        {
            bell.Play("In");
            followButton.normalText.DOText("Unfollow", 0.3f).PlayForward();

            Task t = Task.WhenAll(ShopFetcher.instance.personalReference.Child("mysubs").Child(DatabaseTimeStamp.myEmail).Child(shopID).SetValueAsync(1),
                ShopFetcher.instance.personalReference.Child("subscription").Child(shopID).Child(DatabaseTimeStamp.myEmail).SetValueAsync(1),
                FirebaseMessaging.SubscribeAsync(string.Format("{0}{1}c", shopID, cle)), AddFollow(shopID));
            while (!t.IsCompleted && !t.IsFaulted && !t.IsCanceled)
                yield return Timing.WaitForSeconds(0.1f);  //this is where it gets stuck, cause SubscribeAsync won't return a state
            subbed = true;

        }
        followButtonButton.interactable = true;

    }

Basically i have multiple shops that i can sub to in order to get notifications from their new stuff.
when i click on sub button, it will simply be inerractable as subscribe/usubscribe never returns a value and the coroutine waits forever
This code worked before version 8.x

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Jul 22, 2021
@chkuang-g
Copy link
Contributor

@OrionDev23 @ModischFabrications

Thanks for reporting this and the sample code.

@ModischFabrications
For this part of the code

                FirebaseMessaging.SubscribeAsync(Topic).ContinueWithOnMainThread(t =>
                {
                    if (t.IsFaulted) throw t.Exception;
                    Debug.Log($"Firebase subscribed successfully");
                });

The exception you threw in the continuation block will be stored in the Task returned by the ContinueWithOnMainThread(). I suspect something went wrong and an exception was thrown. Could you try to log it before you rethrow it and see what it says?

Also, did you override firebase_messaging_auto_init_enabled like @maniaks1 did in #1088?

@OrionDev23
You case does seem similar to #1088. Did you override firebase_messaging_auto_init_enabled like @maniaks1 did in #1088?

I'll add more details in #1088

@chkuang-g chkuang-g added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Jul 23, 2021
@OrionDev23
Copy link
Author

@chkuang-g
Thanks for the reply.
No i didn't

So i guess i'll stick up with 7.2 for android for now and 8.1 for ios as it doesn't have any problem.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Jul 23, 2021
@chkuang-g
Copy link
Contributor

Got it. As I described in #1088 (comment), firebase_messaging_auto_init_enabled probably does not matter here.

Since this is a duplicated bug, I will close this and move the conversation to #1088 for issue management sake. I will escalate this issue to the team.

Thanks for the reporting.

@chkuang-g
Copy link
Contributor

Duplicate of #1088

@chkuang-g chkuang-g marked this as a duplicate of #1088 Jul 23, 2021
@firebase firebase locked and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants