Integração de atividade ao vivo com o Adobe Experience Platform Mobile SDK mobile-live-config-sdk

Nesta página: integre o Adobe Experience Platform Mobile SDK ao seu aplicativo iOS para que ele possa registrar, exibir e receber atualizações de atividades em tempo real na Tela de Bloqueio e na Ilha Dinâmica.

O Adobe Experience Platform Mobile SDK fornece suporte integrado para as atividades do Apple Live. Isso permite que seu aplicativo exiba atualizações dinâmicas e em tempo real diretamente na Tela de bloqueio e na Ilha dinâmica sem abrir o aplicativo.

  1. Importar módulos obrigatórios

    Importar os seguintes módulos: AEPMessaging, AEPMessagingLiveActivity, ActivityKit.

  2. Definir atributos

    Em conformidade com LiveActivityAttributes, inclua LiveActivityData e um ContentState atributos.

  3. Registrar atividade ao vivo

    Use Messaging.registerLiveActivity() após a inicialização do SDK.

  4. Criar configuração de widget

    Implemente ActivityConfiguration para a interface Tela de Bloqueio e Ilha Dinâmica.

  5. Iniciar uma atividade Live localmente (opcional)

    A atividade online pode ser iniciada remotamente por meio do Journey Optimizer ou localmente dentro do código do aplicativo.

  6. Adicionar suporte de depuração (opcional)

    Implementar o LiveActivityAssuranceDebuggable para Assurance.

Verifique se as versões mínimas a seguir estão instaladas para garantir a configuração e a compatibilidade corretas.

Pré-requisitos:

  • iOS:

    • iOS16.1 ou posterior: funcionalidade básica de atividade online
    • iOS 17.2+: suporte push-to-start
    • iOS 18+: suporte ao canal de transmissão
  • Xcode: 14.0 ou posterior

  • Swift: 5.7 ou posterior

  • Dependências: AEPCore, AEPMessaging, AEPMessagingLiveActivity, ActivityKit

  • AEP Mobile SDK versão: iOS Messaging 5.11.0 ou posterior

Etapa 1: importar módulos obrigatórios import

Para começar, primeiro você precisa importar os seguintes módulos: AEPMessaging, AEPMessagingLiveActivity, ActivityKit.

import AEPMessaging
import AEPMessagingLiveActivity
import ActivityKit

Etapa 2: definir os atributos de atividade online attributes

Crie uma estrutura que esteja em conformidade com o protocolo LiveActivityAttributes. Isso define o estado dos dados estáticos e do conteúdo dinâmico para a atividade Live.

Os principais componentes incluem:

  • liveActivityData (obrigatório) que contém dados específicos do Adobe Experience Platform.

    • Para usuários individuais: Use LiveActivityData(liveActivityID: "unique-id")
    • Para difusão: Use LiveActivityData(channelID: "channel-id")
  • Atributos estáticos, propriedades personalizadas específicas ao seu caso de uso, por exemplo, restaurantName.

  • ContentState que define dados dinâmicos que podem ser atualizados durante o ciclo de vida da atividade Live. Deve estar em conformidade com Codable e Hashable.

  • A enumeração LiveActivityOrigin especifica se uma atividade foi iniciada localmente no aplicativo ou remotamente por meio de uma notificação push-to-start, com suporte no iOS 17.2 e posterior. Esse valor permite que o SDK diferencie entre atividades online iniciadas localmente e acionadas remotamente durante a coleta de dados.

Exemplos

@available(iOS 16.1, *)
struct FoodDeliveryLiveActivityAttributes: LiveActivityAttributes {
    // Mandatory: AEP Integration Data
    var liveActivityData: LiveActivityData

    // Static Attributes: Custom properties that do not change
    var restaurantName: String

    // Dynamic Content State: Data that can be updated
    struct ContentState: Codable, Hashable {
        var orderStatus: String
    }
}
@available(iOS 16.1, *)
public struct LiveActivityData: Codable {
    /// Unique identifier for broadcast Live activity channels
    public let channelID: String?

    /// Unique identifier for individual Live activity
    public let liveActivityID: String?

    /// Indicates local vs remote creation
    public let origin: LiveActivityOrigin?

    // Initializers
    public init(channelID: String)        // For broadcast Live activity
    public init(liveActivityID: String)   // For individual Live activity
}

Você também pode registrar vários tipos de atividade ao vivo para seu aplicativo:

if #available(iOS 16.1, *) {
    Messaging.registerLiveActivity(AirplaneTrackingAttributes.self)
    Messaging.registerLiveActivity(FoodDeliveryLiveActivityAttributes.self)
    Messaging.registerLiveActivity(GameScoreLiveActivityAttributes.self)
}

Etapa 3: registrar atividade online register

Registre seus tipos de atividade Live no AppDelegate após a inicialização do SDK. Isso permite:

  • Habilita a coleção automática de token de push-para-início (iOS 17.2+)
  • Coleta tokens de atualização de atividade em tempo real automaticamente
  • Permite o gerenciamento do ciclo de vida e o rastreamento de eventos

Exemplo de uma atividade Live de entrega de alimentos:

if #available(iOS 16.1, *) {
    Messaging.registerLiveActivity(FoodDeliveryLiveActivityAttributes.self)
}

Etapa 4: criar widgets de atividade em tempo real widgets

Uma atividade Live é exibida por meio de widgets. Você precisa criar um pacote de widget e uma configuração:

Exemplo de uma atividade Live de entrega de alimentos:

@main
struct FoodDeliveryWidgetBundle: WidgetBundle {
    var body: some Widget {
        FoodDeliveryLiveActivityWidget()
    }
}

@available(iOS 16.1, *)
struct FoodDeliveryLiveActivityWidget: Widget {
    var body: some WidgetConfiguration {
        ActivityConfiguration(for: FoodDeliveryLiveActivityAttributes.self) { context in
            // Lock Screen UI
            VStack {
                Text("Order from \(context.attributes.restaurantName)")
                Text("Status: \(context.state.orderStatus)") // possible status may include "Ordered", "Order accepted", "Preparing", "On the Way","Delivered"
            }
        } dynamicIsland: { context in
            // Dynamic Island UI
            DynamicIsland {
                // Expanded UI
            } compactLeading: {
                // Compact leading UI
            } compactTrailing: {
                // Compact trailing UI
            } minimal: {
                // Minimal UI
            }
        }
    }
}

Etapa 5: iniciar uma atividade online localmente (opcional) local

Embora o Journey Optimizer possa iniciar atividades online remotamente, você também pode iniciá-las localmente:

Exemplo de uma atividade Live de entrega de alimentos:

let attributes = FoodDeliveryLiveActivityAttributes(
    liveActivityData: LiveActivityData(liveActivityID: "order123"),
    restaurantName: "Pizza Palace"
)

let contentState = FoodDeliveryLiveActivityAttributes.ContentState(
    orderStatus: "Ordered"
)

let activity = try Activity<FoodDeliveryLiveActivityAttributes>.request(
    attributes: attributes,
    contentState: contentState,
    pushType: .token
)

Etapa 6: adicionar suporte de depuração (opcional) debug

Se necessário, você pode depurar esquemas de atividade ao vivo no Adobe Assurance:

Exemplo de uma atividade Live de entrega de alimentos:

@available(iOS 16.1, *)
extension FoodDeliveryLiveActivityAttributes: LiveActivityAssuranceDebuggable {
    static func getDebugInfo() -> (attributes: FoodDeliveryLiveActivityAttributes, state: ContentState) {
        return (
            FoodDeliveryLiveActivityAttributes(
                liveActivityData: LiveActivityData(liveActivityID: "debug-order-123"),
                restaurantName: "Debug Restaurant"
            ),
            ContentState(orderStatus: "Ordered")
        )
    }
}

Recursos adicionais

Para obter uma documentação abrangente do SDK e detalhes de implementação:

TIP
Se você estiver tendo problemas com o registro de token, alinhamento de carga ou entrega de atividades em tempo real, consulte Solucionar problemas de atividades em tempo real para obter diretrizes detalhadas de depuração.
AI Knowledge Reference

This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.

For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.

  • TL;DR: This page explains how to integrate the Adobe Experience Platform Mobile SDK into an iOS app so it can register, display, and receive real-time Live activity updates on the Lock Screen and Dynamic Island.

Intents:

  • Import the required modules AEPMessaging, AEPMessagingLiveActivity, and ActivityKit
  • Define Live activity attributes conforming to LiveActivityAttributes, including LiveActivityData and a ContentState
  • Register Live activity types with Messaging.registerLiveActivity() after SDK initialization
  • Create a widget configuration (ActivityConfiguration) for both the Lock Screen and Dynamic Island
  • Optionally start a Live activity locally and add Assurance debug support

Glossary:

  • LiveActivityAttributes: The protocol a struct conforms to, defining both the static data and the dynamic content state for a Live activity (product-specific)
  • LiveActivityData: A required property containing Adobe Experience Platform-specific data; liveActivityID for individual users, channelID for broadcast (product-specific)
  • ContentState: Dynamic data that can be updated during the Live activity lifecycle; must conform to Codable and Hashable
  • LiveActivityOrigin: An enumeration specifying whether an activity was initiated locally or remotely via a push-to-start notification, supported in iOS 17.2 and later (product-specific)
  • Messaging.registerLiveActivity(): The call used after SDK initialization to register Live activity types (product-specific)
  • ActivityConfiguration: The widget configuration implemented for the Lock Screen and Dynamic Island interface
  • LiveActivityAssuranceDebuggable: The protocol implemented to debug Live activity schemas in Adobe Assurance (product-specific)

Guardrails:

  • iOS: 16.1 or later for basic Live activity functionality; 17.2 or later for push-to-start; 18 or later for broadcast channel support (minimum versions).
  • Xcode 14.0 or later (minimum version).
  • Swift 5.7 or later (minimum version).
  • AEP Mobile SDK: iOS Messaging 5.11.0 or later (minimum version).
  • Required dependencies: AEPCore, AEPMessaging, AEPMessagingLiveActivity, ActivityKit.
  • liveActivityData is required and contains Adobe Experience Platform-specific data; ContentState must conform to Codable and Hashable.

Terminology:

  • Canonical name: Adobe Experience Platform Mobile SDK — Acronym: AEP Mobile SDK — variants: Mobile SDK, messaging SDK
  • Synonyms: “push-to-start” = “remotely triggered start, supported in iOS 17.2 and later”
  • Do not confuse: “liveActivityID” (individual users) ≠ “channelID” (broadcast)
  • Do not confuse: “start a Live activity locally” (initiated within the application code) ≠ “start remotely via push-to-start” (triggered remotely through Journey Optimizer)

FAQ:

  • Q: Which modules must I import? — AEPMessaging, AEPMessagingLiveActivity, and ActivityKit.
  • Q: What is the minimum iOS version? — iOS 16.1 or later for basic functionality; iOS 17.2 or later for push-to-start; iOS 18 or later for broadcast channel support.
  • Q: Which AEP Mobile SDK version is required? — iOS Messaging 5.11.0 or later.
  • Q: How do I register Live activity types? — Use Messaging.registerLiveActivity() in your AppDelegate after SDK initialization; you can register multiple Live activity types.
  • Q: Can I start a Live activity without Journey Optimizer? — Yes, a Live activity can be initiated locally within the application code (optional), in addition to being started remotely through Journey Optimizer.
recommendation-more-help
journey-optimizer-help