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

[Bug]: NullReferenceException at OneSignalSDK.OneSignalAndroid.get_PushSubscriptionState on Android

Open oliverebert opened this issue 1 year ago • 1 comments

What happened?

Some of our users with Android 13 get this error:

Non-fatal Exception: java.lang.Exception: NullReferenceException : Object reference not set to an instance of an object. at OneSignalSDK.OneSignalAndroid.get_PushSubscriptionState(OneSignalSDK.OneSignalAndroid)

Steps to reproduce?

Happens sometimes with Android 13 devices

What did you expect to happen?

no NullReferenceException.

Unity version

2021.3.24f1

OneSignal Unity SDK version

3.0.7

Platform

Android

Relevant log output

Non-fatal Exception: java.lang.Exception: NullReferenceException : Object reference not set to an instance of an object.
       at OneSignalSDK.OneSignalAndroid.get_PushSubscriptionState(OneSignalSDK.OneSignalAndroid)

Code of Conduct

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

oliverebert avatar Jun 09 '23 13:06 oliverebert

Had same problem ! Now using 3.0.9 SDK and this code for Init and Prompt internal async void InitializeOneSignal() { Debug.Log("Starting One Signal Init !"); OneSignal.Default.Initialize(m_OneSignalAppId); var result = await OneSignal.Default.PromptForPushNotificationsWithUserResponse(); Debug.Log("Notifications_PermissionChanged - " + result); }

and its working :) also i am on Unity 2022.3.x if it helps :)

G-r-i-n-c-h avatar Jun 29 '23 22:06 G-r-i-n-c-h