Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Firebase Cloud Messaging
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
Firebase Cloud Messaging (FCM) là một giải pháp nhắn tin đa nền tảng cho phép bạn gửi tin nhắn một cách đáng tin cậy.
Bằng cách sử dụng
FCM, bạn có thể thông báo cho ứng dụng khách rằng có email mới hoặc dữ liệu khác để đồng bộ hoá. Bạn có thể gửi thông báo để tăng mức độ tương tác và giữ chân người dùng. Đối với các trường hợp sử dụng như nhắn tin nhanh, một tin nhắn có thể chuyển tải trọng tối đa 4096 byte đến ứng dụng khách.
Bạn đã sẵn sàng bắt đầu? Chọn nền tảng:
iOS+
Android
Web
Flutter
Unity
C++
Các chức năng chính
Gửi thông báo hoặc tin nhắn dữ liệu |
Gửi thông báo hiển thị cho người dùng.
Hoặc gửi thông báo dữ liệu và xác định hoàn toàn những gì xảy ra trong mã ứng dụng. Xem phần
Các loại thông báo. |
Nhắm mục tiêu thông báo linh hoạt |
Phân phối thông báo đến ứng dụng khách theo 3 cách: đến một thiết bị, đến nhóm thiết bị hoặc đến các thiết bị đã đăng ký chủ đề.
|
Tính năng này hoạt động như thế nào?
Việc triển khai FCM bao gồm hai thành phần chính để gửi và nhận:
- Một môi trường đáng tin cậy như Cloud Functions for Firebase hoặc máy chủ ứng dụng để tạo, nhắm mục tiêu và gửi thông báo.
- Ứng dụng khách Apple, Android hoặc web (JavaScript) nhận thông báo qua dịch vụ truyền tải dành riêng cho nền tảng tương ứng.
Bạn có thể gửi thông báo qua Firebase Admin SDK hoặc giao thức máy chủ FCM.
Bạn có thể sử dụng
Trình soạn thông báo để kiểm thử và gửi thông báo tiếp thị hoặc tương tác bằng cách sử dụng tính năng phân tích và nhắm mục tiêu tích hợp mạnh mẽ hoặc phân khúc đã nhập tuỳ chỉnh.
Hãy xem tổng quan về cấu trúc để biết thêm thông tin chi tiết và quan trọng về các thành phần của FCM.
Đường dẫn triển khai
|
Thiết lập SDK FCM |
Thiết lập Firebase và FCM trên ứng dụng theo hướng dẫn thiết lập cho nền tảng của bạn. |
|
Phát triển ứng dụng khách |
Thêm tính năng xử lý thông báo, logic đăng ký chủ đề hoặc các tính năng không bắt buộc khác vào ứng dụng khách. Trong quá trình phát triển, bạn có thể dễ dàng gửi thông báo kiểm thử từ
Trình soạn thông báo. |
|
Phát triển máy chủ ứng dụng |
Quyết định xem bạn muốn sử dụng Firebase Admin SDK hay giao thức máy chủ để tạo logic gửi – logic để xác thực, tạo yêu cầu gửi, xử lý phản hồi, v.v. Sau đó, hãy xây dựng logic trong môi trường đáng tin cậy của bạn. |
Các bước tiếp theo
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-17 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-17 UTC."],[],[],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)."]]