[Bug]: PushSubscriptionStateChanged not run with userid
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
- [X] I agree to follow this project's Code of Conduct
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?