Configure the Manifest File

We will configure the manifest file so as to set the class names of the necessary services for push notification.

Add two sections marked with the <!-- *** add following lines *** --> and <!-- *** up to this point *** --> to your AndroidManifest.xml file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.pushtest" >
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- *** add following lines *** -->
        <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>
        <!-- *** up to this point *** -->

    </application>
</manifest>

We will implement the MyFirebaseInstanceIDService and MyFirebaseMessagingService later in this tutorial.

Settings necessary for the FCM library are automatically added by the manifest merger of Android Studio. You can view the entire settings in the "Merged Manifest" tab while AndroidManifest.xml is opened in Android Studio. Be careful about merged settings in <uses-permission>.

Next we will start the implementation: Implement Your Application.


<< Configure the Build Environment Implement Your Application >>