Live Activity Update Not Working Consistently in the Background

Hi everyone,

I’m working on implementing Live Activities in my app, and I’ve encountered an issue where the Live Activity updates work intermittently when the app is in the background. Sometimes they update correctly, but at other times, they don’t update at all, even though they should be running in the background.

However, when the app is brought to the foreground, the updates happen correctly.

A few things I’ve checked:

The app is using ActivityKit to update the Live Activity with Activity.update(). I’ve enabled the necessary background modes in the Capabilities section.

Is there a possibility that I’m hitting the system budget limit while experiencing this issue? If this is a limitation, how can I avoid it or manage this situation?

Has anyone else faced this issue? Any advice or potential solutions would be greatly appreciated!

Thank you!

It sounds like you may be trying to update your Live Activity from the background. The only supported way is by using push notifications, unless as you've observed, your app is in the foreground.

There is an in-app example of push updates to Live Activities in the CarPlay Quick Ordering Sample.

When testing you will want to enable frequent updates as well.

Hopefully this helps.

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)
}
}
}

Additionally, in the Project Info.plist, I have set

Supports Live Activities Frequent Updates = YES;.

Also, I am receiving silent push notifications with a payload from the backend service to update the Live Activity.

Live Activity Update Not Working Consistently in the Background
 
 
Q