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

[question]: Getting Error On Logout Call #715

Closed
1 task done
G-r-i-n-c-h opened this issue Apr 4, 2024 · 7 comments
Closed
1 task done

[question]: Getting Error On Logout Call #715

G-r-i-n-c-h opened this issue Apr 4, 2024 · 7 comments

Comments

@G-r-i-n-c-h
Copy link

G-r-i-n-c-h commented Apr 4, 2024

How can we help?

Hey,
Got some problem Calling logout and reciving something like that

Must call 'initWithContext' before 'logout'
java.lang.Exception: Must call 'initWithContext' before 'logout'
at com.onesignal.internal.OneSignalImp.logout(OneSignalImp.kt:423)
at com.onesignal.OneSignal.logout(OneSignal.kt:193)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.-$$Nest$mnativeRender(Unknown Source:0)
at com.unity3d.player.UnityPlayer$F$a.handleMessage(Unknown Source:122)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.unity3d.player.UnityPlayer$F.run(Unknown Source:24)
at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.AndroidJavaObject._CallStatic (System.IntPtr methodID, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0

does anyone have the same problem ?

Code of Conduct

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

shepherd-l commented Apr 5, 2024

Thanks for sharing!

What version of the OneSignal Unity SDK and Unity Editor are you using?

Are you able to reproduce this error? And could you provide the steps to do so

Can you provide your entire log with verbose logging turned on by calling OneSignal.Debug.LogLevel = LogLevel.Verbose before initializing

@G-r-i-n-c-h
Copy link
Author

So, Problem is that i am getting this really random.
In my solution different user can login and logout.

Unity 2022.3.22f,
Onesignal 5.1.1.

@shepherd-l
Copy link
Contributor

shepherd-l commented Apr 5, 2024

Where are you calling OneSignal.Logout()? Could you provide steps to what you are doing in your code?

Are you calling OneSignal.Logout() before OneSignal.Initialize(appId)? OneSignal.Initialize(appId) should be called first on app startup because it initializes the OneSignal SDK.

@G-r-i-n-c-h
Copy link
Author

When user logs in with his account i am calling
OneSignal.Initialize(AppID);
Then waiting for user response to set external user id with this
OneSignal.Login(CurrentUserData.id);
After that user can log out any time and log in again same flow is applied.

@shepherd-l
Copy link
Contributor

Can a user be logged out without calling OneSignal.Initialize(appId) on a new cold start?
OneSignal.Initialize needs to be called on every new cold start of the application before any methods should be used.

@G-r-i-n-c-h
Copy link
Author

Got it. that was a case i was calling only once init and then only user login/logout.
Will continue checking if all good will update here.

@shepherd-l
Copy link
Contributor

Closing due to inactivity. If you are still having issues, feel free to open a new issue

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