iOS Live Activities

A Live Activity displays current data from your app on the iPhone Lock Screen and in the Dynamic Island. Live Activities are an AXP feature.

Airship Live Activity support allows an activity with a token to be named on a channel. You can then use that name to send updates through APNs. The name can be unique to the device or shared across multiple devices. Airship handles mapping the name back to the token for the specified audience and sends an update to each one. Minimum SDK required: iOS 16.10.0.

Tracking activities

To support Live Activities, you must call restore once after takeOff during application(_:didFinishLaunchingWithOptions:) with all the Live Activity types that you might track with Airship. This allows Airship to resume tracking of any previously tracked activities across sessions.

Airship.takeOff(config, launchOptions: launchOptions)

Task {
    await Airship.channel.restoreLiveActivityTracking { restorer in
        await restorer.restore(
            forType: Activity<DeliveryAttributes>.self
        )
        await restorer.restore(
            forType: Activity<SomeOtherAttributes>.self
        )
    }
}

Once a Live Activity is created, you can then track it with Airship using:

Task {
    await Airship.channel.trackLiveActivity(
        activity,
        name: "order-1234"
    )
}

Sending updates

Once an activity is tracked with Airship, you can send an update through the Push API by specifying a live_activity payload.

In this example, an update is being sent to all channels that have a Live Activity named order-1234. An audience can be specified to restrict who receives the update.

{
    "audience": "all",
    "device_types": [
        "ios"
    ],
    "notification": {
        "ios": {
            "live_activity": {
                "name": "order-1234",
                "event": "update",
                "content_state": {
                    "stopsAway": "0",
                    "driver": "Jeff Moleyes"
                },
                "dismissal_date": 1666261020,
                "alert": {
                    "title": "Order Delivered",
                    "body": "Hope you enjoy!"
                },
                "priority": 10
            }
        }
    }
}