Firebase Cloud Messagingplat_iosplat_androidplat_webplat_cppplat_unity

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost.

Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

Already using Google Cloud Messaging? Learn more about your options.

iOS SETUP Android Setup Web Setup C++ Setup Unity Setup

Key capabilities

Send notification messages or data messages Send notification messages that are displayed to your user. Or send data messages and determine completely what happens in your application code. See Message types.
Versatile message targeting Distribute messages to your client app in any of 3 ways—to single devices, to groups of devices, or to devices subscribed to topics.
Send messages from client apps Send acknowledgments, chats, and other messages from devices back to your server over FCM’s reliable and battery-efficient connection channel.

How does it work?

Firebase Cloud Messaging architecture diagram

An FCM implementation includes two main components for sending and receiving:

  1. A trusted environment such as Cloud Functions for Firebase or an app server on which to build, target, and send messages.
  2. An iOS, Android, or web (JavaScript) client app that receives messages.

You can send messages via the Admin SDK or the HTTP and XMPP APIs. For testing or for sending marketing or engagement messages with powerful built-in targeting and analytics, you can also use the Notifications composer.

Implementation path

Set up the FCM SDK Set up Firebase and FCM on your app according to the setup instructions for your platform.
Develop your client app Add message handling, topic subscription logic, or other optional features to your client app. During the development, you can easily send test messages from the Notifications composer.
Develop your app server Decide whether you want to use the Admin SDK or one of the server protocols to create your sending logic—logic to authenticate, build sendrequests, handle responses, and so on. Then build out the logic in your trusted environment. Note that if you want to use upstream messaging from your client applications, you must use XMPP, and that Cloud Functions does not support the persistent connection required by XMPP.

Next steps

  • Run the Android or iOS Quickstart sample. These samples let you run and review code to send a test message to a single device using the Firebase console.

  • Try the tutorials for Android or iOS.

  • Add Firebase Cloud Messaging to your Android, iOS, or Web app.

  • Set up your trusted environment. If you are writing your sending logic in Node.js, you can use the Admin Node.js SDK's FCM API and readily deploy your code on Cloud Functions for Firebase. Alternatively, you can get help with server development using the raw protocols from the server setup guide, guides to sending messages with your app server, and the complete references for HTTP and XMPP.

  • Learn more about sending data payloads, setting message priority, and other messaging options that are available with FCM.

  • Migrate your existing Android or iOS GCM implementation to use Firebase Cloud Messaging.

Şunun hakkında geri bildirim gönderin...

Yardım mı gerekiyor? Destek sayfamızı ziyaret edin.