происходит, когда вы предупреждаете людей об обновлении вашей живой активности
с конфигурацией оповещения. < /P>
< /blockquote>
Система отображает презентацию экрана блокировки в качестве баннера для обновления живой активности, если: < /p>
< />
. /> < /li>
Вы передаете AlertConfiguration к обновлению (_: alertConfiguration

function < /p>
< /li>
< /ul>
Я прошел их демо -видео и передала конфигурацию Alert < /code> при следующем: < /p>
struct ParkWidgetAttributes: ActivityAttributes {
var startDate: Date
var endDate: Date
// 'ContentState' represents the dynamic content of the Live Activity.
public struct ContentState: Codable, Hashable {
// Dynamic stateful properties about your activity go here!
var parkingTimer: ClosedRange
}
}
func startLiveActivity() {
let now = Date.now
let future = Calendar.current.date(byAdding: .minute, value: minutes, to: now)!
let dateRange = now...future
// (1) Fixed Attributes
let activityAttributes = ParkWidgetAttributes(startDate: now, endDate: future)
// (2) Content State
let initialContentState = ParkWidgetAttributes.ContentState(parkingTimer: dateRange)
let activityContent = ActivityContent(
state: initialContentState,
staleDate: future
)
do {
let activity = try Activity.request(attributes: activityAttributes,
content: activityContent)
// Pass an AlertConfiguration to the update(_:alertConfiguration:) function
Task {
let alertConfig = AlertConfiguration(
title: "Alert title",
body: "Alert body",
sound: .default
)
await activity.update(activityContent, alertConfiguration: alertConfig)
}
} catch (let error) {
print("Error requesting Parking Live Activity \(error.localizedDescription).")
}
}
< /code>
Используя выше реализацию, живая активность появляется на экране блокировки для обоих устройств (с динамическим островом и без него). Но для разблокированного экрана он появляется только на устройстве с динамичным островом.
Подробнее здесь: https://stackoverflow.com/questions/783 ... mic-island