You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In callback method i use UnityEngine.Application.version which requires to be called on main thread. I suggest to dispatch onesignal callbacks in unity to main thread. Or update documentation for transparency. In OneSignal versions 2.* java code usedunitySendMessage which guarantee that callback will be invoked in main thread.
In fresher versions OneSignal introduced a UnityMainThreadDispatch which only using for OneSiganl.Default.GetTags() calls. I suggest to wrap OneSignal.Default.NotificationOpened, OneSignal.Default.NotificationWillShow, OneSignal.Default.NotificationPermissionChanged in UnityMainThreadDispatch.Post(). Also i submitted a bug with UnityMainThreadDispatch, see #542
Steps to reproduce?
1. Install OneSignal 3.0.4
2. Use any main thread dependent api in OneSignal callback methods
3. Launch Android app
4. Send a notification from OneSignal console
5. Got an exception in OneSignal.Default.NotificationWillShow callback
What did you expect to happen?
The callbacks calls not in main thread in unity
Unity version
2020.3.32
OneSignal Unity SDK version
3.0.4
Platform
Android
Relevant log output
2022-10-17 12:56:15.517 19938-20182/com.game.game E/Unity: UnityException: get_version can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. at AnalyticsTracker+<LogEventImplementation>d__10.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Arikaton
changed the title
[Bug]: Get a thread exception in
[Bug]: Get a thread exception in OneSignal Callback methods
Oct 17, 2022
Apologies that this issue has gone stale. In v5 of our Unity SDK, we have changed it so that callbacks are invoked on the main Unity thread. I haven’t seen any further reports of this. Please try upgrading the OneSignal SDK and if this is still an issue, please open a new report with updated information.
What happened?
In callback method i use
UnityEngine.Application.version
which requires to be called on main thread. I suggest to dispatch onesignal callbacks in unity to main thread. Or update documentation for transparency. In OneSignal versions 2.* java code usedunitySendMessage
which guarantee that callback will be invoked in main thread.In fresher versions OneSignal introduced a UnityMainThreadDispatch which only using for
OneSiganl.Default.GetTags()
calls. I suggest to wrapOneSignal.Default.NotificationOpened, OneSignal.Default.NotificationWillShow, OneSignal.Default.NotificationPermissionChanged
in UnityMainThreadDispatch.Post(). Also i submitted a bug with UnityMainThreadDispatch, see #542Steps to reproduce?
What did you expect to happen?
The callbacks calls not in main thread in unity
Unity version
2020.3.32
OneSignal Unity SDK version
3.0.4
Platform
Android
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: