---
layout: integration
title: Push notifications with FCM
description: Integrate Firebase Cloud Messaging (FCM) with Appwrite to send push notifications to iOS, Android and web applications.
date: 2024-07-30
featured: false
isPartner: true
isNew: false
cover: /images/integrations/push-fcm/cover.avif
category: messaging
product:
    avatar: '/images/integrations/avatars/fcm.avif'
    vendor: Firebase
    description: 'Firebase Cloud Messaging is a cross-platform messaging solution from Google that enables you to send notifications and messages to users across Android, iOS, and web applications.'
platform:
    - 'Self-hosted'
    - 'Cloud'
images:
    - /images/integrations/push-fcm/cover.avif
    - /images/integrations/push-fcm/private-key.avif
    - /images/integrations/push-fcm/provider.avif
---

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution from Google that enables you to send notifications and messages to users across Android, iOS, and web applications. It supports both notification messages displayed by the system UI and data messages handled by your app’s code.

# How does the integration work?

You can use the FCM provider in Appwrite Messaging to send push notifications to your users’ iOS, Android, and web apps. These can be used to send app updates, special offers, instant notifications, reminders, and more.

# How to implement

To implement the FCM provider in Appwrite Messaging, there are several steps you must complete:

## Step 1: Sign up on Firebase

First, you must [sign up for a Firebase account](https://firebase.google.com/) and create a new project. Head to the **Project settings** page, click on the **Service accounts** tab, and **generate new private key**. Download the JSON file for later use.

![Firebase service account private key](/images/integrations/push-fcm/private-key.avif)

You must also verify that FCM has been enabled on your project by visiting the **Cloud Messaging** tab. If FCM is disabled, click the three-dots menu, open the link, and click **Enable**.

## Step 2: Add FCM provider to your Appwrite project

For this step, you must [create an account on Appwrite Cloud](https://cloud.appwrite.io/register) or [self-host Appwrite](https://appwrite.io/docs/advanced/self-hosting) if you haven’t already. In your Appwrite project, head over to the **Messaging** page, click on the **Providers** tab, and **create a new push notifications provider**.

Select **FCM** and upload the JSON file you downloaded from Firebase.

![FCM provider](/images/integrations/push-fcm/provider.avif)

## Step 3: Test the provider

To test the provider on mobile apps, there are some additional configuration steps:

**Android with FCM**

1. Install the `com.google.firebase:firebase-messaging` Firebase SDK.
2. In your Firebase console, navigate to **Settings** > **General** > **Your apps** > add an **Android** app.
3. Register and download your `google-services.json` config file.
4. Add `google-services.json` at the root of your project.
5. Add Google Services class path to your app-level Gradle dependencies block `"com.google.gms:google-services:4.4.0"`.
6. Add the Google Services plugin to your app-level Gradle in the plugins block as `"com.google.gms.google-services"`.
7. Add notification handler service to `AndroidManifest.xml` inside the application tag, alongside other activities. Find an example of this service in the [Send push notification](https://appwrite.io/docs/products/messaging/send-push-notifications#add-targets) journey.

```xml
<service android:name="<YOUR_NOTIFICATION_HANDLER_SERVICE>" android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

```

**iOS with FCM**

1. In your Firebase console, navigate to **Settings** > **General** > **Your apps** > add an **iOS** app.
2. Register and download your `GoogleService-Info.plist` and add it to the root of your project.
3. Head to **Apple Developer Member Center** > **Program resources** > **Certificates, Identifiers & Profiles** > **Keys**. The key needs **Apple Push Notification Service** enabled.
4. Create a new key, note down the key ID, and download your key.
5. In the Firebase console, go to *Settings*> **Cloud Messaging** > **APNs authentication key** > click **Upload**. Then, upload your key here.
6. Add push notification capability to your app by clicking your root-level app in XCode > **Signing & Capabilities** > + Capabilities > Search for **Push Notifications**.
7. If using SwiftUI, disable swizzling by setting `FirebaseAppDelegateProxyEnabled` to `NO` in your `Info.plist`.

After that, you can follow the [Send push notifications](https://appwrite.io/docs/products/messaging/send-push-notifications) flow to test your provider.

# Read more about FCM and Appwrite Messaging

If you would like to learn more about FCM and Appwrite Messaging, we have some resources that you should visit:

- [Set up the FCM provider in Appwrite Messaging](https://appwrite.io/docs/products/messaging/fcm)
- [Send push notifications through Appwrite Messaging](https://appwrite.io/docs/products/messaging/send-push-notifications)
- [Best practices for sending push notifications](https://appwrite.io/blog/post/push-notifications-best-practices)
- [Appwrite Messaging API reference](https://appwrite.io/docs/references/cloud/server-nodejs/messaging)
