Calling firebase.message().requestPermission()
gives:
TypeError: Cannot read property 'name' of undefined
at nativeModuleKey (native.js:24)
at getNativeModule (native.js:26)
at requestPermission (index.js:98)
at runCallEffect (proc.js:524)
at runEffect (proc.js:446)
at next (proc.js:326)
at currCb (proc.js:399)
at proc.js:510
at exec (scheduler.js:25)
at flush (scheduler.js:66)
at asap (scheduler.js:39)
The problem is here?
https://github.com/invertase/react-native-firebase/blob/a605a703fb942c309e651fd889fc3755834a419e/lib/utils/native.js
const nativeModuleKey = (module: ModuleBase): string =>
`${module._serviceUrl || module.app.name}:${module.namespace}`;
Is module.app null? Anyone else got this?
We called this method in another section of our app and it worked, now we moved to a better place for us and it nows gives this error. Anyone know what is happening?
tested on iOS for now
iOS
Xcode 9.03, iOS 11
?
RN: 0.53
RNFirebase Version:
firebase version: 4.0.3
Firebase Module:
Messaging
We know we are using an old version, but we really would like to not update for now...
Looks like problem with context... but where you loose it I do not know. My problem was with redux-saga yield call(firebase.messaging().requestPermission)
-> yield call([firebase.messaging(), 'requestPermission'])
FWIW: I received a similar issue but from firebase/dist because I was not smart and tried doing the following:
const batch = new firestore.batch()
return batch.update(updateFn).commit()
Rather than separating the update and commit as well as removing new from firestore.batch()
const batch = firestore.batch()
batch.update(updateFn)
return batch.commit()
I'm posting this here just in case anyone else gets here by searching for firebase or firestore & "Cannot read property 'name' of undefined"
I had the same issue with firebase and sagas. Using async where possible works too. For example, from:
const initialNotification = yield call(firebase.notifications().getInitialNotification);
to
async function getInitialNotification() {
return await firebase.notifications().getInitialNotification();
}
// In your saga
const initialNotification = yield call(getInitialNotification);
Most helpful comment
Looks like problem with context... but where you loose it I do not know. My problem was with redux-saga
yield call(firebase.messaging().requestPermission)
->yield call([firebase.messaging(), 'requestPermission'])