-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels