NativeScript / firebase

Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
https://docs.nativescript.org/plugins/firebase-core.html
Apache License 2.0
56 stars 50 forks source link

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

Closed PeterStaev closed 2 months ago

PeterStaev commented 8 months ago

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: https://github.com/NativeScript/firebase/blob/0636cd44f691ab9100df63b7f7b39dcfb542c2ef/packages/firebase-messaging-core/index.android.ts#L207-L213

Which was changed in the bump deps commit: https://github.com/NativeScript/firebase/commit/0636cd44f691ab9100df63b7f7b39dcfb542c2ef#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: https://github.com/NativeScript/firebase/blob/0636cd44f691ab9100df63b7f7b39dcfb542c2ef/packages/firebase-messaging-core/index.android.ts#L218-L225 Or the previous init in the constructor should be returned. No idea why it was delay loaded in the first place...

triniwiz commented 7 months ago

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

skhye05 commented 6 months ago

@triniwiz do you know when we can have a fix for this?

SingleMalted commented 4 months ago

@triniwiz Has this issue, using ._native instead of .native, been patched?