Old questions but still relevant so here's an updated answer:
As of now (sept 2020) only implementation 'com.google.firebase:firebase-messaging:20.2.4'
is required in your app/build.gradle file (see referenced official doc).
To further add information that I've struggled to find elsewhere when I've researched how to implement push notifications for Android:
I'm assuming you're using FirebaseInstanceId to retrieve the Instance ID token created by Firebase and are following the guide (see linked documentation). If your main goal is to implement push notifications and you're using React Native I've found you don't need to create the MyFirebaseMessagingService that extends FirebaseMessagingService - you can implement the library react-native-firebase/app and react-native-firebase/messaging to access the token in clients App.
Install both @react-native-firebase/app
and @react-native-firebase/messaging
Then in your frontend App.js:
import messaging from '@react-native-firebase/messaging';
async function requestUserPermission() {
const getFcmToken = async () => {
const fcmToken = await messaging().getToken();
if (fcmToken) {
console.log(fcmToken);
console.log('Your Firebase Token is:', fcmToken);
} else {
console.log('Failed', 'No token received');
}
};
const authStatus = await messaging().requestPermission();
const enabled =
authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
authStatus === messaging.AuthorizationStatus.PROVISIONAL;
if (enabled) {
getFcmToken();
console.log('Authorization status:', authStatus);
}
}
requestUserPermission();
I'm sure this can be refactored, please suggest edits :)
Official documentation Firebase
React Native Firebase library