Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): an expired Live Activity no longer leaves a second card #15254

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/15254/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 24 additions and 5 deletions.

x
0 of 2 viewed, 2 left
24 additions and 5 deletionspatches/expo-widgets@58.0.11.patchModified
View file
@@ -1,5 +1,5 @@
diff --git a/build/Widgets.types.d.ts b/build/Widgets.types.d.ts
-index c9f4dfe..dc0792e 100644
+index c9f4dfe1f10a3a65ab72bd7e639f6f6d148e5f95..dc0792e1cd7b6762394de5e3fefa0863a253f70c 100644
--- a/build/Widgets.types.d.ts
+++ b/build/Widgets.types.d.ts
@@ -93,6 +93,10 @@ export type LiveActivityEnvironment = {
@@ -13,8 +13,27 @@
/**
* Whether the activity is displayed in a context with reduced luminance.
* @platform iOS 16+
+diff --git a/ios/LiveActivityFactory.swift b/ios/LiveActivityFactory.swift
+index 29e4f1566d188665e301d32bc1ad85640f83e68c..7143f9a1c06245d16649b981d7f5cde1d8868217 100644
+--- a/ios/LiveActivityFactory.swift
++++ b/ios/LiveActivityFactory.swift
+@@ -19,6 +19,14 @@ final class LiveActivityFactory: SharedObject {
+ throw LiveActivitiesNotSupportedException()
+ }
+
++ // iOS ends an activity after 8 hours but leaves it frozen on the Lock Screen for up to
++ // 4 more. getInstances() can't see it, so a caller starting a replacement would leave
++ // both cards visible. Dismiss the ended ones now.
++ for activity in Activity<LiveActivityAttributes>.activities
++ where activity.content.state.name == name && activity.activityState == .ended {
++ Task { await activity.end(nil, dismissalPolicy: .immediate) }
++ }
++
+ do {
+ let initialState = LiveActivityAttributes.ContentState(name: name, props: props)
+ let activity = try Activity.request(