Skip to content

Iniciar actividad en vivo

post

/messages/live_activity/start

Utiliza este punto de conexión para iniciar remotamente actividades en vivo mostradas en tu aplicación iOS. Este punto de conexión requiere una configuración adicional.

Después de crear una actividad en vivo, puedes hacer una solicitud POST para iniciar remotamente tu actividad para cualquier segmento dado. Para más información sobre las actividades en vivo de Apple, consulta Iniciar y actualizar actividades en vivo con notificaciones push de ActivityKit.

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

Requisitos previos

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

  • Genera una clave de API con el permiso messages.live_activity.start.
  • Crea una actividad en vivo utilizando el SDK de Braze para Swift.

Límite de velocidad

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

Cuerpo de la solicitud

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "app_id": "(required, string) App API identifier retrieved from the Developer Console.",
  "activity_id": "(required, string) Define a custom string as your `activity_id`. You will use this ID when you wish to send update or end events to your Live Activity.",
  "activity_attributes_type": "(required, string) The activity attributes type you define within `liveActivities.registerPushToStart` in your app",
  "activity_attributes": "(required, object) The static attribute values for the activity type (such as the sports team names, which don't change)",
  "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.",
  "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": "(required, object) Include an `apple_push` object to define a push notification that creates an alert for the user, displayed on paired watchOS devices. Should include `notification.alert.title` and `notification.alert.body`",
  // One of the following:
  "external_user_ids": "(optional, array of strings) see external user identifier, maximum 50",
  "custom_audience": "(optional, connected audience object) see connected audience",
  "segment_id": "(optional, string) see segment identifier"
}

Parámetros de la solicitud

Ejemplo de solicitud

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
curl --location --request POST 'https://rest.iad-01.braze.com/messages/live_activity/start' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {YOUR-REST-API-KEY}' \
--data-raw '{
    "app_id": "{YOUR-APP-API-IDENTIFIER}",
    "activity_id": "football-chiefs-bills-2024-01-21",
    "content_state": {
        "teamOneScore": 0,
        "teamTwoScore": 0
    },
    "activity_attributes_type": "FootballActivity",
    "activity_attributes": {
        "team1Name": "Chiefs",
        "team2Name": "Bills"
    },
    "dismissal_date": "2024-01-22T00:00:00+0000",
    "stale_date": "2024-01-22T16:55:49+0000",
    "notification": {
        "alert": {
            "body": "The game is starting! Tune in soon!",
            "title": "Chiefs v. Bills"
        }
    },
    // One of the following required:
    "segment_id": "{YOUR-SEGMENT-API-IDENTIFIER}", // Optional
    "custom_audience": {...}, // Optional
    "external_user_ids": ["user-id1", "user-id2"], // Optional
}'

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 de 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!