OneSignal-Unity-SDK icon indicating copy to clipboard operation
OneSignal-Unity-SDK copied to clipboard

[question]: Getting Error On Logout Call

Open G-r-i-n-c-h opened this issue 1 year ago • 6 comments

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

  • [X] I agree to follow this project's Code of Conduct

G-r-i-n-c-h avatar Apr 04 '24 21:04 G-r-i-n-c-h

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

shepherd-l avatar Apr 05 '24 15:04 shepherd-l

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.

G-r-i-n-c-h avatar Apr 05 '24 16:04 G-r-i-n-c-h

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.

shepherd-l avatar Apr 05 '24 21:04 shepherd-l

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.

G-r-i-n-c-h avatar Apr 06 '24 08:04 G-r-i-n-c-h

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.

shepherd-l avatar Apr 08 '24 18:04 shepherd-l

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.

G-r-i-n-c-h avatar Apr 09 '24 10:04 G-r-i-n-c-h

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

shepherd-l avatar Sep 12 '24 17:09 shepherd-l