This document describes the APIs for managing Live Activities. It covers how to report start tokens, push tokens, and activity status.
Report a start token
To remotely start a Live Activity using Alibaba Cloud Push, you must first obtain the activity's start token from the Apple Push Notification service (APNs) and then report it from the device.
Start tokens reported to the Alibaba Cloud Push server are valid for up to 90 days.
API definition
+ (void)registerLiveActivityStartToken:(NSData *)startToken
forActivityAttributes:(NSString *)activityAttributes
withCallback:(CallbackHandler)callback;Parameters
Parameter | Type | Required | Description |
startToken | NSData | Yes | The startToken returned by the APNs server. |
activityAttributes | NSString | Yes | The activity template name. |
callback | Block | No | The callback function for the registration result. |
Report a push token
After a Live Activity starts, it is assigned a pushToken for future status updates. You must report the activity ID and the pushToken to the Alibaba Cloud Push server.
Push tokens reported to the Alibaba Cloud Push server are valid for up to 3 days. However, because a Live Activity can last for a maximum of 8 hours, the token's effective validity is also limited to 8 hours.
API definition
+ (void)registerLiveActivityPushToken:(NSData *)pushToken
forActivityId:(NSString *)activityId
withCallback:(CallbackHandler)callback;Parameters
Parameter | Type | Required | Description |
pushToken | NSData | Yes | The pushToken returned by the APNs server. |
activityId | NSString | Yes | The activity ID. |
callback | Block | No | The callback function for the registration result. |
Report activity status
After a Live Activity starts, you can report its status to the Alibaba Cloud Push server to improve the push experience for the Dynamic Island.
API definition
+ (void)syncLiveActivityState:(NSString *)state
forActivityId:(NSString *)activityId
withCallback:(CallbackHandler)callback;Parameters
Parameter | Type | Required | Description |
state | NSString | Yes | The activity status: active | ended | dismissed | stale |
activityId | NSString | Yes | The activity ID. |
callback | Block | No | The callback function for the reporting result. |