Integration von Live-Aktivitäten mit dem Adobe Experience Platform Mobile SDK mobile-live-config-sdk

Auf dieser Seite: Integrieren Sie das Adobe Experience Platform Mobile SDK in Ihre iOS-App, damit es Live-Aktivitätsaktualisierungen in Echtzeit auf dem Sperrbildschirm und auf Dynamic Island registrieren, anzeigen und empfangen kann.

Das Adobe Experience Platform Mobile SDK bietet integrierte Unterstützung für Live-Aktivitäten von Apple. Dadurch kann Ihre App dynamische Aktualisierungen in Echtzeit direkt auf dem Sperrbildschirm und auf der Dynamic Island anzeigen, ohne dass die App geöffnet werden muss.

  1. Importieren erforderlicher Module

    Importieren Sie die folgenden Module: AEPMessaging, AEPMessagingLiveActivity, ActivityKit.

  2. Definieren von Attributen

    Nehmen Sie eine Anpassung an LiveActivityAttributes vor und schließen Sie die Attribute LiveActivityData und ContentState ein.

  3. Registrieren von Live-Aktivitäten

    Verwenden Sie Messaging.registerLiveActivity() nach der SDK-Initialisierung.

  4. Erstellen einer Widget-Konfiguration

    Implementieren Sie ActivityConfiguration sowohl für den Sperrbildschirm als auch für die Dynamic Island-Oberfläche.

  5. Lokales Starten einer Live-Aktivität (optional)

    Live-Aktivitäten können entweder remote über Journey Optimizer oder lokal im Anwendungs-Code initiiert werden.

  6. Hinzufügen von Debugging-Unterstützung (optional)

    Implementieren Sie LiveActivityAssuranceDebuggable für Assurance.

Stellen Sie sicher, dass mindestens die folgenden Versionen installiert sind, um eine korrekte Konfiguration und Kompatibilität zu gewährleisten.

Voraussetzungen:

  • iOS:

    • iOS 16.1 oder höher: Grundlegende Funktionen von Live-Aktivitäten
    • iOS 17.2 oder höher: Push-to-Start-Unterstützung
    • iOS 18 oder höher: Unterstützung für Übertragungskanäle
  • Xcode: 14.0 oder höher

  • Swift: 5.7 oder höher

  • Abhängigkeiten: AEPCore, AEPMessaging, AEPMessagingLiveActivity, ActivityKit

  • AEP Mobile SDK-Version: iOS Messaging 5.11.0 oder höher

Schritt 1: Importieren der erforderlichen Module import

Zunächst müssen Sie die folgenden Module importieren: AEPMessaging, AEPMessagingLiveActivity, ActivityKit.

import AEPMessaging
import AEPMessagingLiveActivity
import ActivityKit

Schritt 2: Definieren der Live-Aktivitätsattribute attributes

Erstellen Sie eine Struktur, die dem Protokoll LiveActivityAttributes entspricht. Dadurch werden sowohl die statischen Daten als auch der Status der dynamischen Inhalte für Ihre Live-Aktivität definiert.

Zu den wichtigsten Komponenten gehören:

  • liveActivityData (erforderlich), enthält Adobe Experience Platform-spezifische Daten.

    • Für einzelne Benutzende: Verwenden Sie LiveActivityData(liveActivityID: "unique-id")
    • Für Übertragung: Verwenden Sie LiveActivityData(channelID: "channel-id")
  • Statische Attribute, benutzerdefinierte Eigenschaften, die für Ihren Anwendungsfall spezifisch sind, z. B. restaurantName.

  • ContentState definiert dynamische Daten, die während des Lebenszyklus der Live-Aktivität aktualisiert werden können. Sie müssen Codable und Hashable entsprechen.

  • Die Auflistung LiveActivityOrigin gibt an, ob eine Aktivität lokal in der App oder remote über eine Push-to-Start-Benachrichtigung initiiert wurde; wird in iOS 17.2 und höher unterstützt. Dieser Wert ermöglicht es dem SDK, bei der Datenerfassung zwischen lokal initiierten und remote ausgelösten Live-Aktivitäten zu unterscheiden.

Beispiele

@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
}

Sie können auch mehrere Typen an Live-Aktivitäten für Ihre App registrieren:

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

Schritt 3: Registrieren der Live-Aktivität register

Registrieren Sie die Typen Ihrer Live-Aktivitäten in AppDelegate nach der SDK-Initialisierung. Das ermöglicht Ihnen Folgendes:

  • Aktiviert die automatische Push-to-Start-Token-Erfassung (iOS 17.2 und höher)
  • Erfasst automatisch Aktualisierungs-Token für Live-Aktivitäten
  • Ermöglicht Lebenszyklus-Management und Ereignis-Tracking

Beispiel für eine Live-Aktivität eines Lebensmittelversands:

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

Schritt 4: Erstellen von Live-Aktivitäts-Widgets widgets

Eine Live-Aktivität wird über Widgets angezeigt. Sie müssen ein Widget-Paket und eine Konfiguration erstellen:

Beispiel für eine Live-Aktivität eines Lebensmittelversands:

@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
            }
        }
    }
}

Schritt 5: Lokales Starten einer Live-Aktivität (optional) local

Journey Optimizer kann Live-Aktivitäten zwar remote starten, Sie können sie aber auch lokal starten:

Beispiel für eine Live-Aktivität eines Lebensmittelversands:

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
)

Schritt 6: Hinzufügen von Debugging-Unterstützung (optional) debug

Bei Bedarf können Sie Schemata von Live-Aktivitäten in Adobe Assurance debuggen:

Beispiel für eine Live-Aktivität eines Lebensmittelversands:

@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")
        )
    }
}

Zusätzliche Ressourcen

Umfassende Dokumentation und Implementierungsdetails zum SDK finden Sie hier:

TIP
Wenn Probleme bei der Token-Registrierung, der Payload-Abstimmung oder der Bereitstellung von Live-Aktivitäten auftreten, finden Sie unter Fehlerbehebung bei Live-Aktivitäten detaillierte Debugging-Anleitungen.
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