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

[@nativescript/firebase-messaging-core][android] Error when trying to register device #249

Open
PeterStaev opened this issue Mar 28, 2024 · 1 comment

Comments

@PeterStaev
Copy link

With the latest changes (3.2.3), I'm getting an error when trying to register device and get token on Android. The same code has been working fine with version 3.2.0. The error is:

Error: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter messaging

From what I was able to troubleshoot it is because of this code that delays loading until first usage:

get native() {
if (!this._native) {
this._native = com.google.firebase.messaging.FirebaseMessaging.getInstance();
}
return this._native;
}

Which was changed in the bump deps commit:
0636cd4#diff-f74cba432ab62cdf5bdf373d3c4c8f3d63dcb1fd4cdcddd473144d2b3c981f80

Seems that this delay load does not work as expected and on all places in the plugin either this._native should be replaced with this.native so that it inits correctly, for example here:

getCurrentToken(): Promise<string> {
return new Promise((resolve, reject) => {
org.nativescript.firebase.messaging.FirebaseMessaging.getToken(
this._native,
new org.nativescript.firebase.messaging.FirebaseMessaging.Callback<string>({
onSuccess(result) {
resolve(result);
},

Or the previous init in the constructor should be returned. No idea why it was delay loaded in the first place...

@triniwiz
Copy link
Member

triniwiz commented Apr 1, 2024

In the newer google services there was an issue when calling the getInstance early would crash so the delay was added, yes you're correct those ._native should be the using the.native

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

No branches or pull requests

2 participants