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 not run with userid #613

Closed
1 task done
mskalash opened this issue Jun 1, 2023 · 2 comments
Closed
1 task done

[Bug]: PushSubscriptionStateChanged not run with userid #613

mskalash opened this issue Jun 1, 2023 · 2 comments

Comments

@mskalash
Copy link

mskalash commented Jun 1, 2023

What happened?

after making the basic settings, the PushSubscriptionStateChanged method is called when the application is first launched, but does not pass the userid.

Steps to reproduce?

1. Install OneSignal
2. Add the line OneSignal.Default.Initialize(osconf.OneSignalKey);
3. Add the line OneSignal.Default.PushSubscriptionStateChanged += (current, previous) => {Debug.Log("Start User " + OneSignal.Default.PushSubscriptionState.userId); };

What did you expect to happen?

At the moment I have created a method that every 4 seconds calls the initialization of a new one and after 3 calls the system starts
IEnumerator WaitOS()
{
yield return new WaitForSeconds(4);
if (!notreload)
{
OneSignal.Default.Initialize(osconf.OneSignalKey);
StartCoroutine(WaitOS());
}
}
example code how it works now

Unity version

2021.3.16 (latest)

OneSignal Unity SDK version

3.0.10

Platform

Android

Relevant log output

when displaying the full log, I see the following moment
2023/06/01 17:48:10.099 8687 8857 Info OneSignal Device registered, UserId = ххххххх
  UserId removed for security purposes
but PushSubscriptionStateChanged method is not called

Code of Conduct

  • I agree to follow this project's Code of Conduct
@shepherd-l
Copy link
Contributor

Thanks for reporting

Could you provide your entire log with verbose logging?
 You can add verbose logging by adding OneSignal.Default.LogLevel = LogLevel.Verbose; before OneSignal.Default.Initialize(appId);
To narrow it the issue down, could you also call OneSignal.Default.Initialize in your code only once?

I tested your steps in a new project and added OneSignal.Default.Initialize and OneSignal.Default.PushSubscriptionStateChanged to Start()

void Start()
{
    OneSignal.Default.Initialize(appId);
    OneSignal.Default.PushSubscriptionStateChanged += (current, previous) => {Debug.Log("Start User " + OneSignal.Default.PushSubscriptionState.userId); };
}

I noticed that in my Android Studio logcat, Debug.Log("Start User " + OneSignal.Default.PushSubscriptionState.userId)shows up when I filter for “Unity” and not “OneSignal” - is this the case for you as well?

@shepherd-l
Copy link
Contributor

Closing due to inactivity. Please try upgrading the OneSignal SDK. Feel free to open a new issue with updated information if you are still experiencing problems

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

2 participants