-
Notifications
You must be signed in to change notification settings - Fork 371
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]: SDK crash on android device | PushRegistrator is null #1782
Comments
Hi @hsaddique thanks for reaching out! We'll look into this. |
Hi @jennantilla. Any update on this? |
HI @jennantilla any update? |
I'm facing this issue too. @jennantilla any update on this? |
@jennantilla it's been more than 6 months, there have been multiple new versions of the SDK, but this error is still not resolved. |
Hello @hsaddique thank you for your patience here. Much of our work in H2 has been on our latest major release where many improvements and enhancements are introduced. We will continue to investigate 4.x.x bugs, though we encourage you to update to 5.1.x as that will be the most-supported release going forward. Please let us know if you have any questions! |
Hi @jennantilla can you please confirm if this bug has been fixed in 5.1.x releases? |
Hello @hsaddique apologies for the delay in response. I have not seen this issue on 5.1.x. If you still are experiencing this on the latest version of the SDK, please let us know and we will be happy to dig into it. Thanks! |
I confirmed this is fixed in the 5.x.x SDK, we use Kotlin to ensure the type can no longer be null: |
What happened?
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.onesignal.PushRegistrator.registerForPush(android.content.Context, java.lang.String, com.onesignal.PushRegistrator$RegisteredHandler)' on a null object reference
at com.onesignal.OneSignal.registerForPushToken(OneSignal.java:1080)
at com.onesignal.OneSignal.startRegistrationOrOnSession(OneSignal.java:1030)
at com.onesignal.OneSignal.doSessionInit(OneSignal.java:1013)
at com.onesignal.OneSignal.init(OneSignal.java:868)
at com.onesignal.OneSignal.setAppId(OneSignal.java:737)
at com.onesignal.OneSignal.reassignDelayedInitParams(OneSignal.java:1181)
at com.onesignal.OneSignal.onRemoteParamSet(OneSignal.java:889)
at com.onesignal.OneSignal$7.complete(OneSignal.java:1122)
at com.onesignal.OneSignalRemoteParams.processJson(OneSignalRemoteParams.java:211)
at com.onesignal.OneSignalRemoteParams.access$100(OneSignalRemoteParams.java:12)
at com.onesignal.OneSignalRemoteParams$1.onSuccess(OneSignalRemoteParams.java:156)
at com.onesignal.OneSignalRestClient$5.run(OneSignalRestClient.java:279)
at java.lang.Thread.run(Thread.java:784)
While investigating the code, the com.onesignal.OneSignal.getPushRegistrator() function has a condition
if (mPushRegistrator != null) {
return mPushRegistrator;
} else {
if (OSUtils.isFireOSDeviceType()) {
mPushRegistrator = new PushRegistratorADM();
} else if (OSUtils.isAndroidDeviceType()) {
if (OSUtils.hasFCMLibrary()) {
mPushRegistrator = getPushRegistratorFCM();
}
} else {
mPushRegistrator = new PushRegistratorHMS();
}
It is returning the object null if the device is android and it doesn't have the fcm library.
Steps to reproduce?
What did you expect to happen?
It should handle the check correctly while identifying device and initializing the SDK correctly
OneSignal Android SDK version
4.8.6
Android version
9, 8
Specific Android models
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: