Skip to content

Actualizar actividad en vivo

post

/messages/live_activity/update

Usa este punto de conexión para actualizar y finalizar las actividades en vivo mostradas por tu aplicación iOS. Este punto de conexión requiere configuración adicional.

Después de registrar una actividad en vivo, puedes pasar una carga útil JSON para actualizar tu servicio de notificaciones push de Apple (APN). Consulta la documentación de Apple sobre la actualización de tu actividad en vivo con cargas útiles de notificaciones push para más información.

Si content-available no está configurado, la prioridad predeterminada del servicio de notificaciones push de Apple (APN) es 10. Si content-available está configurado, esta prioridad es 5. Consulta el objeto push de Apple para más detalles.

Requisitos previos

Para usar este punto de conexión, tendrás que completar lo siguiente:

  • Generar una clave de API con el permiso messages.live_activity.update.
  • Registrar una actividad en vivo de forma remota o local utilizando el SDK Swift de Braze.

Límite de velocidad

Aplicamos el límite de velocidad predeterminado de Braze de 250 000 solicitudes por hora a este punto de conexión, como se documenta en Límites de velocidad de la API.

Cuerpo de la solicitud

1
2
3
4
5
6
7
8
9
{
   "app_id": "(required, string) App API identifier retrieved from the Developer Console.",
   "activity_id": "(required, string) When you register your Live Activity using launchActivity, you use the pushTokenTag parameter to name the Activity’s push token to a custom string. Set activity_id to this custom string to define which Live Activity you want to update.",
   "content_state": "(required, object) You define the ContentState parameters when you create your Live Activity. Pass the updated values for your ContentState using this object. The format of this request must match the shape you initially defined.",
   "end_activity": "(optional, boolean) If true, this request ends the Live Activity.",
   "dismissal_date": "(optional, datetime in ISO-8601 format) The time to remove the Live Activity from the user’s UI. If this time is in the past, the Live Activity will be removed immediately.",
   "stale_date": "(optional, datetime in ISO-8601 format) The time the Live Activity content is marked as outdated in the user’s UI.",
   "notification": "(optional, object ) Include an `apple_push` object to define a push notification that creates an alert for the user."
 }

Request parameters

Example request

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
curl --location --request POST 'https://rest.iad-01.braze.com/messages/live_activity/update' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {YOUR-REST-API-KEY}' \
--data-raw '{
    "app_id": "{YOUR-APP-API-IDENTIFIER}",
    "activity_id": "live-activity-1",
    "content_state": {
        "teamOneScore": 2,
        "teamTwoScore": 4
    },
    "end_activity": false,
    "dismissal_date": "2023-02-28T00:00:00+0000",
    "stale_date": "2023-02-27T16:55:49+0000",
    "notification": {
        "alert": {
            "body": "It's halftime! Let's look at the scores",
            "title": "Halftime"
        }
    }
}'

Respuesta

Hay dos respuestas de código de estado para este punto de conexión: 201 y 4XX.

Ejemplo de respuesta correcta

Se devuelve un código de estado 201 si la solicitud se formateó correctamente y la recibimos. El código de estado 201 podría devolver el siguiente cuerpo de respuesta.

1
2
3
{
  "message": "success"
}

Ejemplo de respuesta de error

La clase de código de estado 4XX indica un error del cliente. Consulta el artículo sobre errores y respuestas de la API para obtener más información sobre los errores que puedes encontrar.

El código de estado 400 podría devolver el siguiente cuerpo de respuesta.

1
2
3
{
    "error": "\nProblem:\n  message body does not match declared format\nResolution:\n  when specifying application/json as content-type, you must pass valid application/json in the request's 'body' "
}
New Stuff!