How to change DynamicIslandMode programmatically in SwiftUI?

136 views Asked by At

There is a DynamicIslandMode which handles Dynamic Island presentations like compactLeading, compactTrailing, expanded, minimal. I want to update Dynamic Island from compact mode to expanded as programmatically without user interaction in the case of another event for the same Live Activity. Is that one possible? Should we continue updating compact presentation in the case of event for that activity?

I don't want to create another Live Activity for the same event.

struct AdventureActivityConfiguration: Widget {
    var body: some WidgetConfiguration {
        ActivityConfiguration(for: AdventureAttributes.self) { context in
            // Create the presentation that appears on the Lock Screen and as a
            // banner on the Home Screen of devices that don't support the
            // Dynamic Island.
            // ...
        } dynamicIsland: { context in
            // Create the presentations that appear in the Dynamic Island.
            DynamicIsland {
                // Create the expanded presentation.
                expandedContent(
                    hero: context.attributes.hero,
                    contentState: context.state,
                    isStale: context.isStale
                )
            } compactLeading: {
                // Create the compact leading presentation.
                // ...
            } compactTrailing: {
                // Create the compact trailing presentation.
                // ...
            } minimal: {
                // Create the minimal presentation.
                // ...
            }
        }
    }
}
0

There are 0 answers