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

[iOS] Firebase Messaging: TypeError: Cannot set property 'delegate' of null #29

Closed
LookinGit opened this issue Dec 23, 2021 · 3 comments

Comments

@LookinGit
Copy link

When on iOS call firebase().messaging(), get this error. I found an error in constructor of class Messaging for iOS

this.#native.delegate = this.#delegate;
in constructor on 48 line.

This error prevents the constructor from finishing executing the code after this line. For this reason, the first call to the function await firebase().messaging().requestPermission() will not work, as and any other methods.

How reproduction this error (only on iOS):

import { firebase } from '@nativescript/firebase-core'
import '@nativescript/firebase-messaging'

...
const messaging = firebase().messaging()
const status = await messaging.requestPermission({ ios: { alert: true } }) // this line not will working
...

I may be wrong, but i think what this issue #24 also related to this error


Until this bug is fixed, may use a temporary solution (hook):

if (isIOS) {
  ;(async () => firebase().messaging())()
}
const status = await firebase().messaging().requestPermission({ ios: { alert: true } })

add this before firebase().messaging().anyMethod()

@LookinGit
Copy link
Author

LookinGit commented Dec 24, 2021

Sorry, i have found a reason 🤦🏼 😆

@iMarwan-k
Copy link

Can you share the solution you found

@LookinGit
Copy link
Author

Can you share the solution you found

Call a firebase().initializeApp() when init app

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