# Migrating to FCM

Batch 1.12 brings full FCM support.\
While new integrations will automatically use it, applications that already used Batch require some changes to explicitly opt-in to a FCM migration. We **strongly** recommend that you update your app as soon as possible.

This documentation describes how to perform this migration.

### Adding Firebase to your project

First, you'll need to make sure that Firebase is fully integrated into your application.

If not, you can follow [Firebase's Get Started guide](https://firebase.google.com/docs/android/setup).\
You can also use Android Studio:

* Open the "Tools" menu, and select "Firebase"
* In the panel that opened, select "Cloud Messaging", and click on "Set up Firebase Cloud Messaging"
* Follow the steps "Connect your app to Firebase" and "Add FCM to your app". Batch already handles the next steps for you.

Your `build.gradle` should contain at least `firebase-core` and `firebase-messaging`:

```
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
```

Finally, make sure you updated Batch to 1.12 or higher.

### Removing deprecated manifest entries

From your Android manifest please remove, if present, the following items:

* BatchPushService
* BatchPushReceiver
* BatchPushInstanceIDService

```xml
<application>
    <service android:name="com.batch.android.BatchPushService" />
    <receiver android:name="com.batch.android.BatchPushReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        [...]
    </receiver>

    <service android:name="com.batch.android.BatchPushInstanceIDService" android:exported="true">
        <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID"/>
        </intent-filter>
    </service>
</application>
```

### Removing old GCM Sender ID

Finally, open up your Application subclass, and delete your `Batch.Push.setGCMSenderID()` call.\
The Sender ID is now read directly from Firebase's configuration.

### Testing it

Once you've done this, the log with your registration ID should change, and say that it is using FCM:

```markdown
Batch.Push: Registration ID/Push Token (FCM): <your device token>
```

If you see `GCM` instead of `FCM` or an error, please try to follow the documentation again, or [contact us](https://batch.com/support).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.batch.com/developer/sdk/android/advanced/fcm-migration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
