Hello again,
First of all, thank you for your response. I’ve been reviewed the CarPlay Quick Ordering Sample, and I’ve implemented the code in the same way as shown in Apple’s WWDC23 presentation. However, I’ve encountered an issue with the stability of background updates in iOS 18.3. Sometimes I can get updates in the background without opening the app, but sometimes I get updates after bringing it to the foreground.
The background updates sometimes don’t work as expected. Could this be an issue with the system budget in iOS 18.3? I’m able to receive updates in the background intermittently, but sometimes it fails. Is there anything specific I should be doing to ensure consistent background updates or any limitations in the background update system that I might be overlooking?
Looking forward to your thoughts and suggestions.
Thank you!
My implementation is as follows:
if let activity = LiveActivityHelper.shared.activity {
do {
try updateActivity(contentState: contentState, staleDate: staleDate)
} catch {
print("Error: \(error.localizedDescription)")
}
} else {
do {
LiveActivityHelper.shared.activity = try Activity.request(
attributes: attributes,
content: .init(
state: contentState,
staleDate: staleDate
),
pushType: .token
)
} catch {
print("Error")
}
}
func updateActivity(contentState: LiveActivityAppAttributes.LiveFlightData, staleDate: Date?) throws {
Task { @MainActor in
await LiveActivityHelper.shared.activity?.update(
.init(
state: contentState,
staleDate: staleDate
)
)
}
}
func endAllActivity() {
Task { @MainActor in
for activity in Activity<LiveActivityAppAttributes>.activities {
await activity.end(dismissalPolicy: .immediate)
}
}
}