Recently started integrating Firebase in my React Native project.
I am using the official Firebase release: https://www.npmjs.com/package/firebase
However when I check the documentation there isn't any specific documentation for react-native only for like typescript etc.
I tried to simply use this on my main page:
import firebase from 'firebase'
var config = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: 'https://xxxxxxxxx.firebaseapp.com/',
databaseURL: 'https://xxxxxxxxx.firebaseio.com',
messagingSenderId: 'xxxxxxxxxx',
debug: true
}
// ini the firebase component
const firebaseRef = firebase.initializeApp(config)
export default class App extends React.Component {
componentDidMount(){
firebase.messaging().getToken()
.then((token) => {
console.warn(token);
});
}
}
However this simple thing just returns an error:
TypeError: undefined is not a function ( evaluating '_firebase2.default.messaging()')
How could I abord the integration of Firebase Cloud Messaging to just receive notififcations.