Android Set Up a Firebase Cloud Messaging Client App on Android


Example

  1. Complete the Installation and setup part to connect your app to Firebase.
    This will create the project in Firebase.

  2. Add the dependency for Firebase Cloud Messaging to your module-level build.gradle file:

dependencies {
     compile 'com.google.firebase:firebase-messaging:10.2.1'
}

Now you are ready to work with the FCM in Android.

FCM clients require devices running Android 2.3 or higher that also have the Google Play Store app installed, or an emulator running Android 2.3 with Google APIs.

Edit your AndroidManifest.xml file

<service
    android:name=".MyFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

<service
    android:name=".MyFirebaseInstanceIDService">
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
    </intent-filter>
</service>