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

[General]: UnityMainThreadDispatch uses [RuntimeInitializeOnLoadMethod]

Open Arikaton opened this issue 3 years ago • 1 comments

What's on your mind?

In OneSignal started from version 3 UnityMainThreadDispatch uses when we call OneSignal.Default.GetTags() in Android platform. The problem is that context getting with [RuntimeInitializeOnLoadMethod] attribute. According to Unity documentation [RuntimeInitializeOnLoadMethod] methods are executed after Awake() event. If we initialize OneSignal in awake and then trying to GetTags we instantly get an exception.

Code of Conduct

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

Arikaton avatar Oct 17 '22 12:10 Arikaton

Thanks for the feedback, what you said is correct. We recommend that you initialize OneSignal in the Start() method. Is this an option for you? If not, could you help us understand why you want to initialize OneSignal in Awake()?

shepherd-l avatar Nov 04 '22 15:11 shepherd-l