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

[Bug]: (Unity/Android) com.onesignal.common.modeling.Model.getStringProperty (java.lang.NullPointerException) #1745

Closed
1 task done
AdamPoncle opened this issue Mar 8, 2023 · 2 comments
Labels

Comments

@AdamPoncle
Copy link

AdamPoncle commented Mar 8, 2023

What happened?

The v5.0.0-beta.1 version of the Unity SDK is causing crashes on multiple devices. We are not doing anything out of the ordinary, just using the SDK for standard push notifications. Our setup is to call:
OneSignal.Default.Initialize("REMOVED_APP_ID");
After which we continue with the rest of our application logic.

From looking through the code, it would seem that the AppId has not been set, therefore it is crashing when trying to retrieve it inside the UpgradeReceiver when calling init.

We are unsure as to why the UpgradeReceiver is being called before our call to OneSignal.Default.Initialize though.

Steps to reproduce?

As described above all we are doing is installing the SDK and calling:

`OneSignal.Default.Initialize("REMOVED_APP_ID");`

After which we do check to see if we have permissions, if if not we do allow the app to request them once again based on some internal config.

What did you expect to happen?

It not crash. Users should be able to enable push notifications as normal.

Unity version

2021.3.18f1

OneSignal Unity SDK version

v5.0.0-beta.1

Platform

Android

Relevant log output

Here is a full stacktrace we have on Android:
Caused by: java.lang.RuntimeException: Unable to start receiver com.onesignal.notifications.receivers.UpgradeReceiver: java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String at android.app.ActivityThread.handleReceiver (ActivityThread.java:4458) at android.app.ActivityThread.access$1700 (ActivityThread.java:261) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2165) at android.os.Handler.dispatchMessage (Handler.java:111) at android.os.Looper.loopOnce (Looper.java:238) at android.os.Looper.loop (Looper.java:357) at android.app.ActivityThread.main (ActivityThread.java:8090) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1026) Caused by java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String at com.onesignal.common.modeling.Model.getStringProperty (Model.kt:215) at com.onesignal.common.modeling.Model.getStringProperty$default (Model.kt:215) at com.onesignal.core.internal.config.ConfigModel.getAppId (ConfigModel.kt:12) at com.onesignal.user.internal.operations.impl.listeners.SubscriptionModelStoreListener.getAddOperation (SubscriptionModelStoreListener.kt:24) at com.onesignal.user.internal.operations.impl.listeners.SubscriptionModelStoreListener.getAddOperation (SubscriptionModelStoreListener.kt:15) at com.onesignal.core.internal.operations.listeners.ModelStoreListener.onModelAdded (ModelStoreListener.kt:36) at com.onesignal.common.modeling.ModelStore$addItem$1.invoke (ModelStore.kt:110) at com.onesignal.common.modeling.ModelStore$addItem$1.invoke (ModelStore.kt:110) at com.onesignal.common.events.EventProducer.fire (EventProducer.kt:40) at com.onesignal.common.modeling.ModelStore.addItem (ModelStore.kt:110) at com.onesignal.common.modeling.ModelStore.addItem$default (ModelStore.kt:98) at com.onesignal.common.modeling.ModelStore.add (ModelStore.kt:46) at com.onesignal.common.modeling.ModelStore.replaceAll (ModelStore.kt:81) at com.onesignal.common.modeling.IModelStore$DefaultImpls.replaceAll$default (IModelStore.kt:81) at com.onesignal.internal.OneSignalImp.createAndSwitchToNewUser (OneSignalImp.kt:396) at com.onesignal.internal.OneSignalImp.createAndSwitchToNewUser$default (OneSignalImp.kt:343) at com.onesignal.internal.OneSignalImp.initWithContext (OneSignalImp.kt:202) at com.onesignal.OneSignal.initWithContext (OneSignal.kt:196) at com.onesignal.notifications.receivers.UpgradeReceiver.onReceive (UpgradeReceiver.kt:47) at android.app.ActivityThread.handleReceiver (ActivityThread.java:4449)

Code of Conduct

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

brismithers commented Mar 9, 2023

Thanks for the feedback @AdamPoncle! We will investigate and let you know if more information from you is needed.

@brismithers
Copy link
Contributor

Closing this, the fix will be included in the next beta release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants