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.
Với Firebase Cloud MessagingHTTP v1 API, bạn có thể gửi, cập nhật và kết thúc thông báo hoạt động trực tiếp từ xa trên các thiết bị iOS. Xin lưu ý rằng bạn cần có iOS 16.1 để sử dụng tính năng hoạt động trực tiếp và iOS 17.2 để bắt đầu thông báo hoạt động trực tiếp từ xa.
Để cập nhật một hoạt động trực tiếp từ xa bằng Firebase Cloud Messaging, bạn cần lấy mã thông báo đẩy từ Apple. Bạn cũng sẽ cần FCM mã thông báo đăng ký cho ứng dụng đích.
Để kết thúc một hoạt động trực tiếp bằng Firebase Cloud Messaging, bạn cần lấy push token (mã thông báo đẩy) từ Apple. Bạn cũng sẽ cần mã thông báo đăng ký FCM cho ứng dụng đích.
[[["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-05 UTC."],[],[],null,["\u003cbr /\u003e\n\nWith the Firebase Cloud Messaging [HTTP v1\nAPI](/docs/reference/fcm/rest/v1/projects.messages/send), you can remotely send,\nupdate, and end live activity notifications on iOS devices. Note that you need\niOS 16.1 to use live activity and iOS 17.2 to remotely start a live activity\nnotification.\n\nBefore you begin\n\nBefore you get started with live activity on Firebase Cloud Messaging, follow the\ninstructions in [Set up a Firebase Cloud Messaging client app on Apple\nplatforms](/docs/cloud-messaging/ios/client) to create and add\nFirebase Cloud Messaging to your client app.\n\nStart a live activity\n\nTo start a live activity remotely using Firebase Cloud Messaging, you need to\nobtain a [push-to-start\ntoken](https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications#Start-new-Live-Activities-with-ActivityKit-push-notifications)\nfrom Apple. You will also need the [FCM registration\ntoken](/docs/cloud-messaging/ios/client#access_the_registration_token) for the\ntarget app.\n\nTo construct a [payload that starts a live\nactivity](https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications#Construct-the-payload-that-starts-a-Live-Activity),\nfill in the\n[`apns.payload`](/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig) field\nfrom the following code sample to remotely start a live activity using\nFCM. You can use the [API\nExplorer](/docs/reference/fcm/rest/v1/projects.messages/send?apix=true&apix_params=%7B%22parent%22%3A%22projects%2F%3Cproject_number%3E%22%2C%22resource%22%3A%7B%22message%22%3A%7B%22token%22%3A%22%3Cfcm_token%3Atest%3E%22%2C%22apns%22%3A%7B%22live_activity_token%22%3A%22%3Clive_activity_push_to_start_token%3E%22%2C%22headers%22%3A%7B%22apns-priority%22%3A%2210%22%7D%2C%22payload%22%3A%7B%22aps%22%3A%7B%22timestamp%22%3A%22%3Ctimestamp%3E%22%2C%22event%22%3A%22start%22%2C%22content-state%22%3A%7B%22demo%22%3A1%7D%2C%22attributes-type%22%3A%22DemoAttributes%22%2C%22attributes%22%3A%7B%22demoAttribute%22%3A1%7D%2C%22alert%22%3A%7B%22title%22%3A%22test%20title%22%2C%22body%22%3A%22test%20body%22%7D%7D%7D%7D%7D%7D%7D)\nto construct and test your payload. \n\n```gdscript\n\"message\":{\n \"token\": \"\u003cfcm_token:test\u003e\",\n \"apns\":{\n \"live_activity_token\": \"\u003clive_activity_push_to_start_token\u003e\",\n \"headers\":{\n \"apns-priority\": \"10\"\n },\n \"payload\":{\n \"aps\": {\n \"timestamp\": \u003ctimestamp\u003e,\n \"event\": \"start\",\n \"content-state\": {\n \"demo\": 1\n },\n \"attributes-type\": \"DemoAttributes\",\n \"attributes\": {\n \"demoAttribute\": 1,\n },\n \"alert\": {\n \"title\": \"test title\",\n \"body\": \"test body\"\n }\n }\n }\n }\n }\n```\n\nUpdate a live activity\n\nTo update a live activity remotely using Firebase Cloud Messaging, you need to\nobtain a [push\ntoken](https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications#Start-a-Live-Activity-that-supports-push-updates-to-push-tokens)\nfrom Apple. You will also need the [FCM registration\ntoken](/docs/cloud-messaging/ios/client#access_the_registration_token) for the\ntarget app.\n\nTo construct a [payload that updates a Live\nActivity](https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications#Construct-the-ActivityKit-remote-push-notification-payload),\nfill in the\n[`apns.payload`](/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig) field\nfrom the following code sample to remotely update a live activity using\nFCM. You can use the [API\nExplorer](/docs/reference/fcm/rest/v1/projects.messages/send?apix=true&apix_params=%7B%22parent%22%3A%22projects%2F%3Cproject_number%3E%22%2C%22resource%22%3A%7B%22message%22%3A%7B%22token%22%3A%22%3Cfcm_token%3Atest%3E%22%2C%22apns%22%3A%7B%22live_activity_token%22%3A%22%3Clive_activity_push_token%3E%22%2C%22headers%22%3A%7B%22apns-priority%22%3A%2210%22%7D%2C%22payload%22%3A%7B%22aps%22%3A%7B%22timestamp%22%3A%22%3Ctimestamp%3E%22%2C%22event%22%3A%22update%22%2C%22content-state%22%3A%7B%22test1%22%3A100%2C%22test2%22%3A%22demo%22%7D%2C%22alert%22%3A%7B%22title%22%3A%22test%20title%22%2C%22body%22%3A%22test%20body%22%7D%7D%7D%7D%7D%7D%7D)\nto construct and test your payload. \n\n```gdscript\n\"message\":{\n \"token\": \"\u003cfcm_token:test\u003e\",\n \"apns\":{\n \"live_activity_token\": \"\u003clive_activity_push_token\u003e\",\n \"headers\":{\n \"apns-priority\": \"10\"\n },\n \"payload\":{\n \"aps\": {\n \"timestamp\": \u003ctimestamp\u003e,\n \"event\": \"update\",\n \"content-state\": {\n \"test1\": 100,\n \"test2\": \"demo\"\n },\n \"alert\": {\n \"title\": \"test title\",\n \"body\": \"test body\"\n }\n }\n }\n }\n }\n}\n```\n\nEnd a live activity\n\nTo end a live activity using Firebase Cloud Messaging, you need to obtain a [push\ntoken](https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications#Start-a-Live-Activity-that-supports-push-updates-to-push-tokens)\nfrom Apple. You will also need the [FCM registration\ntoken](/docs/cloud-messaging/ios/client#access_the_registration_token)\nfor the target app.\n\nTo construct [a payload that ends a live\nactivity](https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications#Construct-the-ActivityKit-remote-push-notification-payload),\nfill in the\n[`apns.payload`](/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig) field\nfrom the following code sample to remotely end a live activity using\nFCM. You can use the [API\nExplorer](/docs/reference/fcm/rest/v1/projects.messages/send?apix=true&apix_params=%7B%22parent%22%3A%22projects%2F%3Cproject_number%3E%22%2C%22resource%22%3A%7B%22message%22%3A%7B%22token%22%3A%22%3Cfcm_token%3Atest%3E%22%2C%22apns%22%3A%7B%22live_activity_token%22%3A%22%3Clive_activity_push_token%3E%22%2C%22headers%22%3A%7B%22apns-priority%22%3A%2210%22%7D%2C%22payload%22%3A%7B%22aps%22%3A%7B%22timestamp%22%3A%22%3Ctimestamp%3E%22%2C%22dismissal-date%22%3A%22%3Cdismissal_date%3E%22%2C%22event%22%3A%22end%22%2C%22content-state%22%3A%7B%22test1%22%3A100%2C%22test2%22%3A%22demo%22%7D%2C%22alert%22%3A%7B%22title%22%3A%22test%20title%22%2C%22body%22%3A%22test%20body%22%7D%7D%7D%7D%7D%7D%7D)\nto construct and test your payload. \n\n```gdscript\n\"message\":{\n \"token\": \"\u003cfcm_token:test\u003e\",\n \"apns\":{\n \"live_activity_token\": \"\u003clive_activity_push_token\u003e\",\n \"headers\":{\n \"apns-priority\": \"10\"\n },\n \"payload\":{\n \"aps\": {\n \"timestamp\": \u003ctimestamp\u003e,\n \"dismissal-date\": \u003cdismissal_date\u003e,\n \"event\": \"end\",\n \"content-state\": {\n \"test1\": 100,\n \"test2\": \"demo\"\n },\n \"alert\": {\n \"title\": \"test title\",\n \"body\": \"test body\"\n }\n }\n }\n }\n }\n}\n```"]]