[WWDC26] Live Activities essentials
이 글은 WWDC 세션의 transcript 와 영상 화면을 Claude Code 로 정리한 글이고, 실제로 쓴 날은 2026-11-25 다. code 는 세션 page 의 snippet 에 빠진 type 을 채워 Xcode 27.0 의 iOS 27 simulator SDK 로 type check 했다.
세션 정보
- 세션: Live Activities essentials
- 길이: 15분 16초
- 공개일: 2026-06-08
- 발표: Adi Ayyakad (System Experience Engineer)
- 코드: 세션 page 의 snippet 9개, sample project 는 없음
한 줄 요약
Live Activity 를 처음 만드는 순서를 data model, view, 시작과 갱신으로 나눠 한 번에 훑는 입문 세션이다. iOS 27 에서 새로 생긴 것은 하나로, Dynamic Island 가 landscape 에서도 보이게 되면서 폭이 모자란 상황을 알려 주는 isDynamicIslandLimitedInWidth environment value 가 들어왔다.
세션의 구성
발표자 한 사람이 커피 주문 앱을 예로 slide 와 code 를 번갈아 보여 준다. Xcode 시연은 없고, code 옆에 그 code 가 만드는 화면을 작게 붙여 두는 방식이다. 세션 page 의 chapter 는 Introduction, Create and update, Optimize 셋이다.
| 순서 | 내용 | 발표 |
|---|---|---|
| 1 | Live Activity 가 나타나는 곳 | Adi Ayyakad |
| 2 | 디자인과 data model | Adi Ayyakad |
| 3 | Lock Screen 과 Dynamic Island 의 view | Adi Ayyakad |
| 4 | 시작과 갱신, push notification | Adi Ayyakad |
| 5 | Landscape, StandBy, small family 에 맞추기 | Adi Ayyakad |
| 6 | App Intents 로 button 넣기 | Adi Ayyakad |
Live Activity 가 나타나는 곳
세션은 code 로 들어가기 전에 Live Activity 가 system 의 어디에 보이는지부터 짚는다. 한 번 만들면 여러 곳에 자동으로 나타나기 때문에, 뒤에 나오는 최적화 이야기가 전부 이 목록에서 출발한다.
Live Activity 란?
Live Activity 는 앱에서 진행 중인 일을 앱을 열지 않고도 보여 주는 system 화면이다. 경기 점수, 배달 상황, timer 처럼 시작과 끝이 있고 그 사이에 상태가 바뀌는 정보에 쓴다. 앱이 ActivityKit 으로 시작하고 갱신하며, 화면은 widget extension 안에서 WidgetKit 과 SwiftUI 로 그린다.
세션이 든 예는 MLB 앱이다.
출처: WWDC26 - Live Activities essentials
iPhone 의 Lock Screen 이다. 시계 아래쪽, 손전등과 camera button 위에 두 팀의 점수 5 대 4 를 보여 주는 Live Activity 가 놓여 있다.
출처: WWDC26 - Live Activities essentials
기기를 쓰는 중에는 Dynamic Island 로 옮겨 간다. Home Screen 위쪽의 sensor 영역 양옆에 팀 logo 와 점수가 하나씩 붙어 있다. 이 상태가 compact presentation 이다.
출처: WWDC26 - Live Activities essentials
Dynamic Island 를 길게 누르면 expanded presentation 으로 커진다. 점수 사이에 주자 상황과 “Top 9, 0-0, 2 outs” 같은 줄이 더 보인다. 세션은 alert 가 붙은 갱신이 올 때도 이 모양으로 커진다고 설명한다.
iOS 27 의 landscape Dynamic Island
세션에서 “새로 생겼다” 고 말하는 유일한 대목이다.
출처: WWDC26 - Live Activities essentials
iPhone 을 가로로 돌려 Photos 의 Library 를 보는 화면이고, 오른쪽 위에 초록색 NEW 배지가 붙어 있다. 화면 왼쪽 끝에 세로로 선 Dynamic Island 가 있고 위아래 끝에 작은 icon 이 하나씩 들어 있다. iOS 27 부터는 Dynamic Island 가 portrait 와 landscape 양쪽에서 보인다.
그 밖의 표시 위치
나머지는 이미 있던 위치들이다. 세션은 이 위치들에 Live Activity 가 “자동으로” 나타난다고 말한다.
출처: WWDC26 - Live Activities essentials
iPhone 을 가로로 두고 충전할 때의 StandBy 다. 화면 전체가 갈색이고 “Espresso”, “Coffee Shop”, “Ordered” 와 세 칸짜리 progress bar 가 크게 보인다.
출처: WWDC26 - Live Activities essentials
iPhone 의 Lock Screen 과 Apple Watch 가 나란히 있다. iPhone 에는 “Espresso 7:41” 과 progress bar 가, Apple Watch 의 Smart Stack 에는 “Coffee Shop”, “Preparing”, “7:41” 을 세로로 쌓고 오른쪽에 원형 icon 을 둔 작은 card 가 보인다. 두 화면의 구성이 다르다는 점이 뒤의 small family 이야기로 이어진다.
출처: WWDC26 - Live Activities essentials
CarPlay Dashboard 다. 지도와 음악 조작 card 아래에 “Coffee Shop”, “Preparing”, “7:49” 를 담은 card 가 들어가 있다. 세션은 이 밖에 macOS 의 menu bar 도 든다. menu bar 화면은 영상에 나오지 않는다.
디자인과 data model
세션이 권하는 순서는 data model 을 정하고, view 를 만들고, 갱신을 붙이는 것이다. 다만 data model 을 정하려면 무엇을 보여 줄지가 먼저 있어야 해서 디자인 이야기가 앞에 온다.
예제 앱과 디자인
출처: WWDC26 - Live Activities essentials
예제로 쓰는 커피 주문 앱이다. Espresso 를 고른 화면에 Size, Milk, Extras 선택지가 있고 맨 아래에 “Place Order $3.50” button 이 있다. 주문을 넣으면 Live Activity 가 시작된다.
디자인에 대한 조언은 짧다. 한눈에 읽히는 정보를 우선하고, Human Interface Guidelines 의 Live Activities 를 따르라는 것이다. 자세한 내용은 Design dynamic Live Activities 세션으로 넘긴다.
Static data 와 dynamic data
디자인이 나오면 그 안의 정보를 둘로 가른다.
출처: WWDC26 - Live Activities essentials
“Plan the data model” slide 다. Lock Screen 디자인 네 개가 세로로 쌓여 있고 가운데 줄만 밝게 강조되어 있다. 위에서부터 “Ordered”, “7:49”, “Ready”, 그리고 “Not Good” 과 “Great” button 이다. 왼쪽 주석은 “Status and time remaining” 이다. 이 장면 앞에서는 반대로 맨 윗줄의 “Espresso” 와 “Coffee Shop” 이 강조되고 “Coffee shop and order” 라는 주석이 붙는다.
- static data: 가게 이름, 음료, 주문 ID. Live Activity 가 살아 있는 동안 바뀌지 않는다.
- dynamic data: 주문 단계, 예상 준비 시각, 평점. 갱신할 때마다 바뀔 수 있다.
갱신할 수 있는 것은 dynamic data 뿐이다. 그래서 “나중에 바뀔 수 있는가” 가 분류 기준이 된다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import ActivityKit
import Foundation
public struct DrinkOrderAttributes: ActivityAttributes {
let shopName: String
let drink: Drink
let orderID: UUID
public struct ContentState: Codable, Hashable {
var phase: DrinkOrder.Phase = .waiting
var estimatedReadyDate: Date
var rating: DrinkOrder.Rating?
}
}
ActivityAttributes
Live Activity 하나의 data 를 설명하는 protocol 이다. struct 자신의 property 가 static data 이고, 안에 정의하는 ContentState 가 dynamic data 다. ContentState 는 Codable 과 Hashable 을 따라야 한다. push notification 으로 갱신할 때 이 type 이 JSON 으로 오가기 때문이다. 문서는 ActivityAttributes 에 있다.
세션은 Drink 와 DrinkOrder 를 보여 주지 않는다. type check 를 위해 아래처럼 채웠다. label 과 showsTimer 는 뒤의 view code 가 쓰는 것이라 함께 넣었다.
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
struct Drink: Codable, Hashable {
var name: String
var symbolName: String
}
struct DrinkOrder {
enum Phase: String, Codable, Hashable, CaseIterable {
case waiting, preparing, ready, completed
var label: String {
switch self {
case .waiting: "Ordered"
case .preparing: "Preparing"
case .ready: "Ready"
case .completed: "Enjoy"
}
}
var showsTimer: Bool { self == .waiting || self == .preparing }
}
enum Rating: String, Codable, Hashable {
case great, poor
}
var id: UUID
var drink: Drink
}
세션 page 의 snippet 과 영상의 slide 는 이름이 조금 다르다. page 는 DrinkOrder.Phase 와 .waiting 을 쓰고, slide 는 Drink.Order.Phase 와 .ordered 를 쓴다. 이 글은 page 쪽을 따랐다.
Lock Screen 과 Dynamic Island 의 view
data model 다음은 화면이다. Live Activity 의 view 는 앱이 아니라 widget extension 에 들어가고, WidgetKit 이 그린다.
ActivityConfiguration
할 일은 세 가지다. 프로젝트에 widget extension 을 추가하고, ActivityConfiguration 을 제공하고, 각 presentation 의 SwiftUI view 를 만든다.
출처: WWDC26 - Live Activities essentials
왼쪽은 ActivityConfiguration 의 뼈대이고 첫 번째 closure 의 ActivityView(context: context) 줄이 강조되어 있다. 오른쪽에는 그 줄이 만드는 Lock Screen 화면, 곧 “Espresso”, “Coffee Shop”, “7:49”, progress bar 가 든 갈색 card 가 붙어 있다.
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
29
30
31
32
import ActivityKit
import SwiftUI
import WidgetKit
struct DrinkOrderLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: DrinkOrderAttributes.self) { context in
ActivityView(context: context)
} dynamicIsland: { context in
DynamicIsland {
DynamicIslandExpandedRegion(.leading) {
ExpandedLeadingView(context: context)
}
DynamicIslandExpandedRegion(.center) {
ExpandedCenterView(context: context)
}
DynamicIslandExpandedRegion(.trailing) {
ExpandedTrailingView(context: context)
}
DynamicIslandExpandedRegion(.bottom) {
ExpandedBottomView(context: context)
}
} compactLeading: {
CompactLeadingView(context: context)
} compactTrailing: {
CompactTrailingView(context: context)
} minimal: {
MinimalView(context: context)
}
}
}
}
ActivityConfiguration
어떤 ActivityAttributes 를 그릴지와 그 화면을 묶는 widget configuration 이다. 첫 번째 closure 가 Lock Screen 용 view 이고 dynamicIsland closure 가 Dynamic Island 용이다. 두 closure 모두 context 를 받는데, 여기에 static data 인 attributes 와 가장 최근의 state 가 들어 있다. 문서는 ActivityConfiguration 에 있다.
DynamicIsland
Dynamic Island 의 네 가지 view 를 한꺼번에 받는 type 이다. 맨 앞 closure 가 expanded, 이어서 compactLeading, compactTrailing, minimal 이다. 문서는 DynamicIsland 에 있다.
ExpandedLeadingView 같은 view 들은 세션에 이름만 나온다. 이 글의 sample 에서는 symbol 하나나 Text 하나를 돌려주는 짧은 view 로 채웠고, 본문에는 싣지 않았다.
Compact 와 minimal
compact presentation 은 sensor 영역의 왼쪽과 오른쪽에 하나씩 놓인다.
출처: WWDC26 - Live Activities essentials
compactLeading 과 compactTrailing 줄이 강조되어 있고 오른쪽에 그 결과가 있다. 검은 island 의 왼쪽에 커피 잔 icon, 오른쪽에 “Picked Up” 이라는 글자가 들어가 있다. 세션의 설명대로 leading 에는 음료 symbol 을, trailing 에는 주문 단계를 넣은 것이다.
출처: WWDC26 - Live Activities essentials
minimal 줄이 강조된 장면이다. 오른쪽 그림에서는 다른 Live Activity 가 island 본체를 차지하고, 커피 주문은 그 옆에 떨어진 작은 원 안에 들어가 있다. minimal view 는 이렇게 Live Activity 여러 개가 동시에 돌 때 쓰인다. 예제는 남은 시간을 원형 gauge 로 그린다.
Expanded
출처: WWDC26 - Live Activities essentials
DynamicIslandExpandedRegion 세 줄이 강조되어 있다. 오른쪽의 커진 island 에는 왼쪽에 커피 잔 icon, 오른쪽에 “Preparing”, 아래쪽에 progress bar 가 놓여 있다.
DynamicIslandExpandedRegion
expanded presentation 안의 한 구역을 채우는 type 이다. 위치는 leading, center, trailing, bottom 넷이다. 이 구역들은 sensor 영역을 둘러싸는 식으로 배치되므로, 내용을 구역에 나눠 넣으면 sensor 를 피하는 계산은 system 이 맡는다. 문서는 DynamicIslandExpandedRegion 에 있다.
시작과 갱신
view 가 준비되면 실제로 띄울 차례다. 세션은 시작하는 방법을 먼저 나열한 뒤 그중 하나만 code 로 보여 준다.
시작하는 세 가지 방법
출처: WWDC26 - Live Activities essentials
“Start a Live Activity” slide 에 세 줄이 있다. “Request from your app”, “Schedule in advance”, “Start with push notifications” 다.
- 앱이 foreground 에 있을 때 ActivityKit 으로 요청한다.
- 특정 시각에 시작하도록 미리 예약한다.
- push notification 으로 시작한다.
세션이 code 로 다루는 것은 첫 번째뿐이다. 나머지 둘은 SDK 에서 해당 API 가 있는 것만 확인했다. 예약은 request(attributes:content:pushType:style:alertConfiguration:start:) 가 iOS 26.0 부터 있고, push 로 시작할 때 쓰는 pushToStartToken 은 iOS 17.2 부터 있다.
앱에서 시작하기
1
2
3
4
5
6
7
8
9
func launchLiveActivity(order: DrinkOrder) throws -> Activity<DrinkOrderAttributes>? {
guard ActivityAuthorizationInfo().areActivitiesEnabled else { return nil }
let attributes = DrinkOrderAttributes(shopName: "Coffee Shop", drink: order.drink, orderID: order.id)
let estimatedReadyDate = Date.now + (15 * 60)
let contentState = DrinkOrderAttributes.ContentState(phase: .waiting, estimatedReadyDate: estimatedReadyDate)
let activityContent = ActivityContent(state: contentState, staleDate: nil)
let activity = try Activity.request(attributes: attributes, content: activityContent)
return activity
}
순서는 네 단계다. Live Activity 가 허용되어 있는지 확인하고, static data 로 attributes 를 만들고, 첫 dynamic data 로 content 를 만든 뒤 요청한다. 예제는 주문 직후 상태로 시작하고 준비 시각을 15분 뒤로 잡는다.
세션 page 의 snippet 은 activity 를 만들기만 하고 함수가 끝난다. 그러면 뒤에서 갱신할 대상이 없으므로 이 글에서는 Activity 를 돌려주도록 바꿨다. 허용되지 않은 경우를 구분하려고 반환 type 은 optional 로 했다.
ActivityAuthorizationInfo
사용자가 이 앱의 Live Activity 를 허용했는지 알려 주는 type 이다. areActivitiesEnabled 가 false 면 요청해도 시작되지 않으므로 먼저 확인한다. 문서는 ActivityAuthorizationInfo 에 있다.
ActivityContent
dynamic data 한 벌과 그 유효 기간을 묶는 type 이다. staleDate 는 이 내용이 낡았다고 볼 시각이다. 그 시각이 지나면 view 쪽에서 낡았다는 표시를 할 수 있다. 예제는 nil 을 넣어 쓰지 않는다. 문서는 ActivityContent 에 있다.
Activity
진행 중인 Live Activity 하나를 가리키는 class 다. request(attributes:content:pushType:) 로 시작하고, 돌려받은 instance 로 갱신하고 끝낸다. 문서는 Activity 에 있다.
앱에서 갱신하기
주문이 다음 단계로 넘어가면 새 content 를 만들어 update 에 넘긴다.
1
2
3
4
5
6
7
8
9
10
11
func markPreparing(_ activity: Activity<DrinkOrderAttributes>, estimatedReadyDate: Date) async {
await activity.update(
ActivityContent(
state: DrinkOrderAttributes.ContentState(
phase: .preparing,
estimatedReadyDate: estimatedReadyDate
),
staleDate: nil
)
)
}
세션 page 에서는 await activity.update(...) 가 함수 밖에 그대로 놓여 있어 빌드되지 않는다. 함수로 감싼 것은 이 글에서 한 일이다. 갱신할 때마다 staleDate 도 새로 줄 수 있다.
Push notification 으로 갱신하기
앱이 떠 있지 않을 때도 상태는 바뀐다. 커피가 준비되는 시점에 사용자가 앱을 열어 두고 있을 가능성은 낮다. 그래서 실제 갱신은 대부분 server 에서 push 로 보낸다.
출처: WWDC26 - Live Activities essentials
“Update with push notifications” slide 다. “Broadcast updates” 아래에 “Large audience” 와 “Channels” 가, “Push notifications” 아래에 “All other use cases” 와 “Push tokens” 가 적혀 있다. 맨 아래에는 문서 제목이 링크로 붙어 있다.
| 전략 | 쓰는 경우 | 대상 지정 |
|---|---|---|
| Broadcast updates | 같은 내용을 수백, 수천 명 이상이 보는 경우. 경기 점수 같은 것 | channel 을 구독 |
| Push notifications | 그 밖의 전부. 개인별 주문 같은 것 | 기기별 push token |
SDK 에서는 이 선택이 request 의 pushType 인자로 나타난다. PushType.token 이 기기별 token 이고 PushType.channel(_:) 이 channel 이며, channel 쪽은 iOS 18.0 부터다. 세션은 여기서 code 를 보여 주지 않고 Starting and updating Live Activities with ActivityKit push notifications 문서로 넘긴다. 커피 주문은 사람마다 다른 내용이므로 token 쪽에 해당한다.
표시 위치별 최적화
여기까지 만들면 Live Activity 는 모든 위치에 나타난다. 하지만 Lock Screen 에 맞춰 만든 view 가 다른 위치에서도 그대로 좋아 보이지는 않는다. 세션의 후반은 문제가 생기는 세 곳을 하나씩 고친다. slide 는 문제 화면에 노란 느낌표를, 고친 화면에 초록 체크를 붙여 구분한다.
Landscape 의 좁은 Dynamic Island
portrait 의 compact view 는 내용에 따라 옆으로 늘어날 수 있다. landscape 에서는 그럴 자리가 없다.
출처: WWDC26 - Live Activities essentials
노란 느낌표가 붙은 화면이다. 가로로 든 iPhone 의 왼쪽 끝에 세로로 선 island 가 있고, 위쪽에 커피 잔 icon 이 있다. 아래쪽 끝의 timer 는 자리가 모자라 “7…” 로 잘려 있다. 남은 시간을 읽을 수 없다.
고치는 방법은 폭이 제한된 상황을 알아채고 trailing view 를 더 작은 것으로 바꾸는 것이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct CompactTrailingView: View {
@Environment(\.isDynamicIslandLimitedInWidth) var isDynamicIslandLimitedInWidth
var context: ActivityViewContext<DrinkOrderAttributes>
var body: some View {
if isDynamicIslandLimitedInWidth {
StepProgressIconView(context: context)
} else if context.state.phase.showsTimer {
EstimatedReadyView(context: context, font: .system(.body).monospacedDigit())
.multilineTextAlignment(.trailing)
.frame(maxWidth: maximumTimerLabelWidth)
} else {
OrderPhaseLabelView(context: context, font: .caption2.bold(), color: .brown)
.multilineTextAlignment(.trailing)
}
}
}
isDynamicIslandLimitedInWidth
Dynamic Island 가 폭을 늘릴 수 없는 상태인지 알려 주는 environment value 다. slide 에서 이 줄에만 NEW 배지가 붙고, SDK 의 availability 도 iOS 27.0 이다. true 일 때는 글자 대신 icon 처럼 폭이 고정된 view 를 돌려주면 된다. 문서는 isDynamicIslandLimitedInWidth 에 있다.
StepProgressIconView, EstimatedReadyView, OrderPhaseLabelView, maximumTimerLabelWidth 는 세션에 정의가 없다. sample 에서는 각각 진행 정도를 그리는 symbol, timer style 의 Text, 단계 이름을 쓰는 Text, 상수 하나로 채웠다.
출처: WWDC26 - Live Activities essentials
초록 체크가 붙은 화면이다. 잘린 timer 가 있던 island 의 아래쪽 끝에 원 안에 종이 든 작은 icon 이 들어가 위쪽의 커피 잔 icon 과 짝을 이룬다.
StandBy 의 배경
StandBy 는 Lock Screen 용 view 를 그대로 가져와 200% 로 키워 보여 준다. view 를 따로 만들지 않아도 된다는 뜻이지만 배경이 문제가 된다.
출처: WWDC26 - Live Activities essentials
노란 느낌표가 붙은 StandBy 화면이다. 검은 화면 한가운데에 갈색 gradient card 가 떠 있고 그 안에 “Espresso”, “7:48”, progress bar 가 있다. card 둘레로 검은 여백이 남아 화면을 다 쓰지 못한다.
원인은 view 가 gradient 배경을 직접 그리고 있다는 데 있다. Lock Screen 에서는 그 배경이 card 를 채우지만 StandBy 에서는 화면보다 작게 남는다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct ActivityView: View {
@Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground
var context: ActivityViewContext<DrinkOrderAttributes>
var body: some View {
DetailView(context: context)
.background {
if showsWidgetContainerBackground {
LinearGradient.barista
}
}
.activityBackgroundTint(.espresso)
}
}
showsWidgetContainerBackground
지금 widget 의 container 배경이 보이는 상황인지 알려 주는 environment value 다. 세션의 설명으로는 Lock Screen 에서 true 다. 이 값이 true 일 때만 gradient 를 그리면 StandBy 에서는 gradient 가 빠진다. 새 API 는 아니고 iOS 15.0 부터 있다. 문서는 showsWidgetContainerBackground 에 있다.
activityBackgroundTint(_:)
Live Activity 의 배경에 입힐 tint 색을 정하는 modifier 다. StandBy 에서는 이 색이 화면 끝까지 채워진다. gradient 를 뺀 자리를 이 색이 대신한다. 문서는 [activityBackgroundTint(:)](https://developer.apple.com/documentation/swiftui/view/activitybackgroundtint%28:%29){:target=”_blank”} 에 있다.
LinearGradient.barista 와 Color.espresso 는 세션의 앱이 정의해 둔 값이다. sample 에서는 갈색 계열 gradient 와 색 하나로 채웠다.
출처: WWDC26 - Live Activities essentials
초록 체크가 붙은 화면이다. 갈색이 화면 가장자리까지 채워져 여백이 없다.
Apple Watch 와 CarPlay 의 small family
Apple Watch 의 Smart Stack 과 CarPlay Dashboard 는 Lock Screen 보다 훨씬 작다. 아무것도 하지 않으면 system 이 가진 view 를 조합해 보여 주는데, 결과가 좋지 않다.
출처: WWDC26 - Live Activities essentials
노란 느낌표가 붙은 CarPlay Dashboard 다. 오른쪽 아래 card 에 “Espresso”, “Coffee Shop”, “7:49”, progress bar 가 들어 있는데, Lock Screen 의 배치를 그대로 줄여 넣은 모양이라 글자가 작고 빽빽하다. 앞에서 본 CarPlay 화면의 “Coffee Shop”, “Preparing”, “7:49” card 와 비교하면 차이가 보인다.
해결은 두 단계다. 먼저 configuration 에 small family 를 지원한다고 선언한다.
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
29
struct DrinkOrderLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: DrinkOrderAttributes.self) { context in
ActivityView(context: context)
} dynamicIsland: { context in
DynamicIsland {
DynamicIslandExpandedRegion(.leading) {
ExpandedLeadingView(context: context)
}
DynamicIslandExpandedRegion(.center) {
ExpandedCenterView(context: context)
}
DynamicIslandExpandedRegion(.trailing) {
ExpandedTrailingView(context: context)
}
DynamicIslandExpandedRegion(.bottom) {
ExpandedBottomView(context: context)
}
} compactLeading: {
CompactLeadingView(context: context)
} compactTrailing: {
CompactTrailingView(context: context)
} minimal: {
MinimalView(context: context)
}
}
.supplementalActivityFamilies([.small])
}
}
그다음 view 에서 family 를 보고 갈라 준다.
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
struct ActivityView: View {
@Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground
@Environment(\.activityFamily) var activityFamily
var context: ActivityViewContext<DrinkOrderAttributes>
var body: some View {
contentView
.background {
if showsWidgetContainerBackground {
LinearGradient.barista
}
}
.activityBackgroundTint(.espresso)
}
@ViewBuilder
var contentView: some View {
if activityFamily == .small {
SmallView(context: context)
} else {
DetailView(context: context)
}
}
}
supplementalActivityFamilies(_:)
Lock Screen 외에 추가로 지원할 activity family 를 선언하는 modifier 다. .small 을 넣으면 Apple Watch 와 CarPlay 에서 이 configuration 의 Lock Screen closure 가 small family 로 불린다. 문서는 [supplementalActivityFamilies(:)](https://developer.apple.com/documentation/swiftui/widgetconfiguration/supplementalactivityfamilies%28:%29){:target=”_blank”} 에 있다.
activityFamily
지금 그려지는 Live Activity 의 family 를 알려 주는 environment value 다. 값은 small 과 medium 둘이다. 문서는 activityFamily 에 있다.
이 둘도 새 API 는 아니다. SDK 의 availability 는 둘 다 iOS 18.0 이다.
출처: WWDC26 - Live Activities essentials
“Small activity family” slide 다. “Adapt to Apple Watch and CarPlay” 한 줄과, 아래에 Bring your Live Activity to Apple Watch 세션이 링크로 걸려 있다. 자세한 내용은 그 세션에 있다는 안내다.
App Intents 로 넣는 button
Live Activity 는 보여 주기만 하는 화면이 아니다. button 을 넣어 앱을 열지 않고 동작을 실행하게 할 수 있다. 예제에서는 주문이 끝난 뒤 음료를 평가하는 button 두 개다.
LiveActivityIntent
출처: WWDC26 - Live Activities essentials
“Add actions with App Intents” slide 다. “Not Good” 과 “Great” button 이 든 card 에서 선 두 개가 내려와 하나로 합쳐지고 RateDrinkIntent 를 가리킨다. button 은 둘이지만 intent 는 하나이고, 어느 쪽인지는 parameter 로 구분한다는 그림이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import ActivityKit
import AppIntents
struct RateDrinkIntent: LiveActivityIntent {
static var title: LocalizedStringResource = "Rate Drink"
@Parameter(title: "Order ID")
var orderID: String
@Parameter(title: "Positive")
var isPositive: Bool
init() {}
init(orderID: String, isPositive: Bool) {
self.orderID = orderID
self.isPositive = isPositive
}
func perform() async throws -> some IntentResult {
await updateLocalDatastore(rating: isPositive ? .great : .poor, dismissPolicy: .after(.now + 15))
return .result()
}
}
LiveActivityIntent
Live Activity 안의 button 이 실행할 수 있는 App Intent 를 나타내는 protocol 이다. perform() 에서 server 요청을 보내거나 database 를 고치는 일을 한다. iOS 17.0 부터 있다. 문서는 LiveActivityIntent 에 있다.
init 두 개는 세션 page 의 snippet 에 없는 것이다. page 의 code 그대로는 RateDrinkIntent(orderID:isPositive:) 가 type 오류로 빌드되지 않았다. @Parameter 가 붙은 property 는 memberwise init 에서 String 이 아니라 wrapper type 을 받기 때문이다. 영상의 slide 는 var orderID: String = "" 처럼 기본값을 주고 있어 page 와 또 다르다. 이 글에서는 명시적 init 을 넣는 쪽으로 풀었다.
updateLocalDatastore(rating:dismissPolicy:) 도 세션에 정의가 없다. 이름과 인자로 보면 평점을 저장하고 Live Activity 를 끝내는 함수다. sample 에서는 아래처럼 채웠다.
1
2
3
4
5
6
7
func updateLocalDatastore(rating: DrinkOrder.Rating, dismissPolicy: ActivityUIDismissalPolicy) async {
for activity in Activity<DrinkOrderAttributes>.activities {
var state = activity.content.state
state.rating = rating
await activity.end(ActivityContent(state: state, staleDate: nil), dismissalPolicy: dismissPolicy)
}
}
ActivityUIDismissalPolicy
끝난 Live Activity 를 화면에서 언제 치울지 정하는 type 이다. 세션의 code 는 .after(.now + 15) 를 넘겨, 평가한 뒤 15초 동안 결과를 보여 주고 치운다. 문서는 ActivityUIDismissalPolicy 에 있다.
위 함수는 진행 중인 주문을 전부 끝낸다. 실제 앱이라면 orderID 로 해당 activity 만 골라야 한다.
Button 에 intent 연결하기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
struct RatingButtons: View {
var context: ActivityViewContext<DrinkOrderAttributes>
var body: some View {
HStack(spacing: 12) {
Button(intent: RateDrinkIntent(
orderID: context.attributes.orderID.uuidString, isPositive: false)) {
Label("Not Good", systemImage: "hand.thumbsdown.fill")
}
.buttonStyle(RatingButtonStyle(color: .red))
Button(intent: RateDrinkIntent(
orderID: context.attributes.orderID.uuidString, isPositive: true)) {
Label("Great", systemImage: "hand.thumbsup.fill")
}
.buttonStyle(RatingButtonStyle(color: .green))
}
}
}
Button(intent:label:)
action closure 대신 App Intent 를 받는 Button 의 init 이다. widget 과 Live Activity 의 view 는 앱 process 밖에서 그려지므로 closure 를 실행할 수 없고, 이 init 으로 intent 를 넘겨야 한다. 문서는 init(intent:label:) 에 있다.
static data 로 넣어 둔 orderID 가 여기서 쓰인다. view 는 context.attributes 에서 주문 ID 를 꺼내 intent 에 실어 보내고, intent 는 그 ID 로 어느 주문인지 안다. RatingButtonStyle 은 세션에 정의가 없어 capsule 배경을 그리는 ButtonStyle 로 채웠다.
세션의 마무리
출처: WWDC26 - Live Activities essentials
“Next steps” slide 에 다섯 줄이 있다.
- Get started with Live Activities
- Model your data for efficient updates
- Create outstanding presentations
- Provide timely updates
- Curate experiences
세션이 다룬 순서를 그대로 다시 적은 목록이다. 마지막 줄에 대해서는 landscape, StandBy, Apple Watch 처럼 위치마다 경험을 다듬으라고 말한다.
정리
“essentials” 라는 제목대로 대부분은 이미 있던 API 를 한 줄로 꿰는 내용이다. 아래 표의 version 은 Xcode 27.0 의 SDK 에서 읽은 것이다.
| 단계 | API | 시작 version |
|---|---|---|
| data model | ActivityAttributes, ContentState | 16.1 |
| view | ActivityConfiguration, DynamicIsland | 16.1 |
| 시작과 갱신 | Activity.request(attributes:content:pushType:), update(_:), ActivityContent | 16.2 |
| 예약 시작 | request(attributes:content:pushType:style:alertConfiguration:start:) | 26.0 |
| broadcast | PushType.channel(_:) | 18.0 |
| StandBy 배경 | showsWidgetContainerBackground, activityBackgroundTint(_:) | 15.0, 16.0 |
| small family | supplementalActivityFamilies(_:), activityFamily | 18.0 |
| button | LiveActivityIntent, Button(intent:label:) | 17.0 |
| landscape 대응 | isDynamicIslandLimitedInWidth | 27.0 |
실제 프로젝트에 가져갈 점은 다음과 같다.
- 정보를 나눌 때의 기준은 “Live Activity 가 도는 동안 바뀌는가” 다. 바뀌는 것만
ContentState에 넣는다. - intent 가 대상을 찾는 데 쓸 ID 는 static data 에 넣어 둔다.
- 이미 Live Activity 가 있는 앱은 iOS 27 에서 landscape 로 돌려 compact trailing view 를 확인한다. 글자를 넣어 뒀다면
isDynamicIslandLimitedInWidth로 icon 을 대신 내야 한다. - Lock Screen view 가 배경을 직접 그린다면
showsWidgetContainerBackground로 감싸고activityBackgroundTint(_:)를 준다. - Apple Watch 와 CarPlay 에 나가는 모양이 마음에 들지 않으면
.smallfamily 를 선언하고 전용 view 를 만든다. - 여러 사람이 같은 내용을 보는 Live Activity 면 channel, 사람마다 다르면 push token 이다.
- 세션 page 의
RateDrinkIntent는 그대로 복사하면 빌드되지 않는다. 기본값을 주거나 init 을 직접 쓴다.