透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Firebase Cloud Messaging
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
Firebase Cloud Messaging (FCM) 是跨平台訊息傳送解決方案,可讓您可靠地傳送訊息。
您可以使用
FCM,通知用戶端應用程式有新的電子郵件或其他資料可同步。您可以傳送通知訊息,以提高使用者的再參與度和留存率。在即時通訊等用途中,訊息可以將最多 4096 個位元組的酬載傳送至用戶端應用程式。
準備好了嗎?選擇平台:
iOS+
Android
網頁版
Flutter
Unity
C++
主要功能
傳送通知訊息或資料訊息 |
傳送通知訊息,向使用者顯示訊息。或是傳送資料訊息,並判斷應用程式的程式碼執行情況。請參閱
訊息類型。 |
多功能訊息指定 |
三種向用戶端應用程式發布訊息的方式任您選擇:對單一裝置、對裝置群組,或對訂閱特定主題的裝置。 |
運作原理
FCM 實作項目包含兩個主要元件,用於傳送和接收:
- 信任的環境,例如 Cloud Functions for Firebase 或應用程式伺服器,可用於建構、指定目標和傳送訊息。
- 透過相應的平台專屬傳輸服務接收訊息的 Apple、Android 或網頁 (JavaScript) 用戶端應用程式。
您可以透過 Firebase Admin SDK 或 FCM 伺服器通訊協定傳送訊息。您可以使用
通知編輯器進行測試,並透過強大的內建指定目標和分析功能,或自訂匯入的區隔傳送行銷或參與度訊息。
請參閱架構總覽,進一步瞭解 FCM 的元件和重要資訊。
實作路徑
|
設定 FCM SDK |
請根據平台的設定說明,在應用程式中設定 Firebase 和 FCM。 |
|
開發用戶端應用程式 |
在用戶端應用程式中新增訊息處理、主題訂閱邏輯或其他選用功能。在開發期間,您可以輕鬆透過
通知編寫工具傳送測試訊息。 |
|
開發應用程式伺服器 |
決定要使用 Firebase Admin SDK 還是伺服器通訊協定來建立傳送邏輯,也就是驗證、建立傳送要求、處理回應等邏輯。接著,在受信任的環境中建立邏輯。 |
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-17 (世界標準時間)。
[null,null,["上次更新時間:2025-08-17 (世界標準時間)。"],[],[],null,["Firebase Cloud Messaging \nplat_ios plat_android plat_web plat_flutter plat_cpp plat_unity \nFirebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send\nmessages. \nUsing 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 4096 bytes to a client app.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nReady to get started? Choose your platform:\n\n[iOS+](/docs/cloud-messaging/ios/client)\n[Android](/docs/cloud-messaging/android/client)\n[Web](/docs/cloud-messaging/js/client)\n[Flutter](/docs/cloud-messaging/flutter/client)\n\n[Unity](/docs/cloud-messaging/unity/client)\n[C++](/docs/cloud-messaging/cpp/client)\n\nKey capabilities\n\n|---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 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](/docs/cloud-messaging/concept-options#notifications_and_data_messages). |\n| 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. |\n\nHow does it work?\n\n\u003cbr /\u003e\n\nAn FCM implementation includes two main components for\nsending and receiving:\n\n1. A trusted environment such as Cloud Functions for Firebase or an app server on which to build, target, and send messages.\n2. An Apple, Android, or web (JavaScript) client app that receives messages via the corresponding platform-specific transport service.\n\n\u003cbr /\u003e\n\nYou can send messages via\nthe [Firebase Admin SDK](/docs/cloud-messaging/server#firebase-admin-sdk-for-fcm) or the\n[FCM server protocol](/docs/cloud-messaging/server#choose).\nYou can use [the Notifications composer](//console.firebase.google.com/project/_/notification) for testing and to send marketing or engagement\nmessages using powerful built-in targeting and analytics or custom\n[imported segments](/docs/projects/import-segments).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSee the [architectural\noverview](/docs/cloud-messaging/fcm-architecture) for more detail and important\ninformation about the components of FCM.\n\n\u003cbr /\u003e\n\nImplementation path\n\n|---|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Set up the FCM SDK | Set up Firebase and FCM on your app according to the setup instructions for your platform. |\n| | 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](//console.firebase.google.com/project/_/notification). |\n| | Develop your app server | Decide whether you want to use the Firebase Admin SDK or the server protocol to create your sending logic---logic to authenticate, build send requests, handle responses, and so on. Then build out the logic in your trusted environment. |\n\nNext steps\n\n- Run the [Android](https://github.com/firebase/quickstart-android/tree/master/messaging)\n or [iOS](https://github.com/firebase/quickstart-ios/tree/master/messaging/)\n Quickstart sample. These samples let you run and review code to send a test\n message to a single device using the Firebase console.\n\n- Learn more about FCM from the\n [architecture overview](/docs/cloud-messaging/fcm-architecture),\n guides to key [FCM concepts](/docs/cloud-messaging/concept-options),\n and best practices guides for [sending messages at scale](/docs/cloud-messaging/scale-fcm)\n and [managing registration tokens](/docs/cloud-messaging/manage-tokens).\n\n- Try the tutorials for [Android](/docs/cloud-messaging/android/first-message)\n or [iOS](/docs/cloud-messaging/ios/first-message).\n\n- Add Firebase Cloud Messaging to your\n [Android](/docs/cloud-messaging/android/client),\n [Apple](/docs/cloud-messaging/ios/client),\n or [Web](/docs/cloud-messaging/js/client) app.\n\n- Set up your trusted environment where you'll build and send message requests.\n You can write sending logic using the\n [Admin SDK](/docs/cloud-messaging/server#firebase-admin-sdk-for-fcm), and\n readily deploy that code on Cloud Functions for Firebase or other cloud\n environments managed by Google.\n Alternatively, you can perform server development using the\n [FCM server protocol](/docs/cloud-messaging/server#choose)."]]