Thông báo có thể đại diện cho nhiều loại dữ liệu đến. Thông thường, các thông báo được gửi đến ứng dụng sau khi nhà phát triển bắt đầu. Các thông báo cũng được gửi đến ứng dụng của bạn để biểu thị các sự kiện đã gửi thông báo, sự kiện lỗi gửi thông báo và sự kiện đã xoá thông báo. Bạn có thể phân biệt các sự kiện đặc biệt này bằng cách kiểm tra trường MessageType.
Đã xoá tin nhắn
Được gửi đến ứng dụng của bạn khi máy chủ FCM xoá các tin nhắn đang chờ xử lý.
MessageType sẽ là "deleted_messages". Tin nhắn có thể bị xoá nếu:
Có quá nhiều thư được lưu trữ trên máy chủ FCM.
Điều này có thể xảy ra khi máy chủ của một ứng dụng gửi hàng loạt thông báo không thu gọn đến các máy chủ FCM trong khi thiết bị đang ở chế độ ngoại tuyến.
Thiết bị đã không kết nối trong một thời gian dài và gần đây (trong vòng 4 tuần qua), máy chủ ứng dụng đã gửi một thông báo đến ứng dụng trên thiết bị đó.
Bạn nên để ứng dụng đồng bộ hoá hoàn toàn với máy chủ ứng dụng sau khi nhận được lệnh gọi này.
Gửi sự kiện
Được gọi khi một thông báo truyền lên đã được gửi thành công đến FCM.
MessageType sẽ là "send_event".
Lỗi khi gửi
Được gọi khi xảy ra lỗi khi gửi thông báo nguồn.
MessageType sẽ là "send_error".
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-03 UTC."],[],[],null,["Receive and handle messages\n\nTo receive messages, your app must assign a callback to the\n[Firebase.Messaging.FirebaseMessaging.MessageReceived](/docs/reference/unity/class/firebase/messaging/firebase-messaging#messagereceived)\nevent handler.\n\n`MessageReceived` Event\n\nBy overriding assigning a callback to\n[Firebase.Messaging.FirebaseMessaging.MessageReceived](/docs/reference/unity/class/firebase/messaging/firebase-messaging#messagereceived)\nyou can perform actions based on the received message and get the message data: \n\n```c#\npublic void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) {\n UnityEngine.Debug.Log(\"From: \" + e.Message.From);\n UnityEngine.Debug.Log(\"Message ID: \" + e.Message.MessageId);\n}\n```\n\nMessages can represent different kinds of incoming data. Most commonly,\nmessages are sent to the app after being initiated by the developer. Messages\nare also sent to you app to represent message sent events, message send error\nevents, and messages deleted events. These special events can be differentiated\nby checking the `MessageType` field.\n\nMessages Deleted\n\nSent to your app when the FCM server deletes pending messages.\n`MessageType` will be `\"deleted_messages\"`. Messages may be deleted if:\n\n1. Too many messages are stored on the FCM server.\n\n This can occur when an app's servers send a bunch of non-collapsible\n messages to FCM servers while the device is offline.\n2. The device hasn't connected in a long time and the app server has\n recently (within the last 4 weeks) sent a message to the app on that\n device.\n\n It is recommended that the app do a full sync with the app\n server after receiving this call.\n\nSend Event\n\nCalled when an upstream message has been successfully sent to FCM.\n`MessageType` will be `\"send_event\"`.\n\nSend Error\n\nCalled when there was an error sending an upstream message.\n`MessageType` will be `\"send_error\"`."]]