Skip to content
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

[Bug]: PushSubscriptionStateChanged event not being fired on Android #668

Open
1 task done
berkayk opened this issue Nov 21, 2023 · 0 comments
Open
1 task done

Comments

@berkayk
Copy link

berkayk commented Nov 21, 2023

What happened?

I am trying to get subscribed users' userId from the PushSubscriptionStateChanged action.

OneSignal.Default.Initialize(OneSignalAppId);
OneSignal.Default.PushSubscriptionStateChanged += OnPushSubscriptionStateChanged;

On iOS everything is fine but on Android, this action is not being fired.

On iOS,

private void OnPushSubscriptionStateChanged(PushSubscriptionState current, PushSubscriptionState previous) {
            if (current.isSubscribed) {
                Debug.Log(current.userId);  // <---    I am able to get users' id here
            }
        }

Why isn't this event being fired on Android?

If I do the following (wait for 5 seconds), I am able to get userId

OneSignal.Default.Initialize(OneSignalAppId);
OneSignal.Default.PushSubscriptionStateChanged += OnPushSubscriptionStateChanged;
await Task.Delay(5000);
Debug.Log("userId = " + OneSignal.Default.PushSubscriptionState.userId);    // This works.

Steps to reproduce?

1. Initialize OneSignal with `OneSignal.Default.Initialize(OneSignalAppId);`
2. Register for PushSubscriptionStateChanged event with `OneSignal.Default.PushSubscriptionStateChanged += OnPushSubscriptionStateChanged;`
3. `OnPushSubscriptionStateChanged` handler is not being called on Android (works on iOS)

What did you expect to happen?

I expected the app to work on the same way like it works on iOS.

Unity version

2022.3.1f1

OneSignal Unity SDK version

3.0.9

Platform

Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant