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 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.
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 or self-host Appwrite 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.
Step 3: Test the provider
To test the provider on mobile apps, there are some additional configuration steps:
Install the com.google.firebase:firebase-messaging Firebase SDK.
In your Firebase console, navigate to Settings > General > Your apps > add an Android app.
Register and download your google-services.json config file.
Add google-services.json at the root of your project.
Add Google Services class path to your app-level Gradle dependencies block "com.google.gms:google-services:4.4.0".
Add the Google Services plugin to your app-level Gradle in the plugins block as "com.google.gms.google-services".
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 journey.
<service android:name="<YOUR_NOTIFICATION_HANDLER_SERVICE>" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
In your Firebase console, navigate to Settings > General > Your apps > add an iOS app.
Register and download your GoogleService-Info.plist and add it to the root of your project.
Head to Apple Developer Member Center > Program resources > Certificates, Identifiers & Profiles > Keys. The key needs Apple Push Notification Service enabled.
Create a new key, note down the key ID, and download your key.
In the Firebase console, go to Settings> Cloud Messaging > APNs authentication key > click Upload. Then, upload your key here.
Add push notification capability to your app by clicking your root-level app in XCode > Signing & Capabilities > + Capabilities > Search for Push Notifications.
If using SwiftUI, disable swizzling by setting FirebaseAppDelegateProxyEnabled to NO in your Info.plist.
After that, you can follow the 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: