Skip to content

Commit 77823bd

Browse files
fix(mobile): an expired Live Activity no longer leaves a second card (pingdotgg#15254)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 65731f9 commit 77823bd

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

‎patches/[email protected]‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/build/Widgets.types.d.ts b/build/Widgets.types.d.ts
2-
index c9f4dfe..dc0792e 100644
2+
index c9f4dfe1f10a3a65ab72bd7e639f6f6d148e5f95..dc0792e1cd7b6762394de5e3fefa0863a253f70c 100644
33
--- a/build/Widgets.types.d.ts
44
+++ b/build/Widgets.types.d.ts
55
@@ -93,6 +93,10 @@ export type LiveActivityEnvironment = {
@@ -13,8 +13,27 @@ index c9f4dfe..dc0792e 100644
1313
/**
1414
* Whether the activity is displayed in a context with reduced luminance.
1515
* @platform iOS 16+
16+
diff --git a/ios/LiveActivityFactory.swift b/ios/LiveActivityFactory.swift
17+
index 29e4f1566d188665e301d32bc1ad85640f83e68c..7143f9a1c06245d16649b981d7f5cde1d8868217 100644
18+
--- a/ios/LiveActivityFactory.swift
19+
+++ b/ios/LiveActivityFactory.swift
20+
@@ -19,6 +19,14 @@ final class LiveActivityFactory: SharedObject {
21+
throw LiveActivitiesNotSupportedException()
22+
}
23+
24+
+ // iOS ends an activity after 8 hours but leaves it frozen on the Lock Screen for up to
25+
+ // 4 more. getInstances() can't see it, so a caller starting a replacement would leave
26+
+ // both cards visible. Dismiss the ended ones now.
27+
+ for activity in Activity<LiveActivityAttributes>.activities
28+
+ where activity.content.state.name == name && activity.activityState == .ended {
29+
+ Task { await activity.end(nil, dismissalPolicy: .immediate) }
30+
+ }
31+
+
32+
do {
33+
let initialState = LiveActivityAttributes.ContentState(name: name, props: props)
34+
let activity = try Activity.request(
1635
diff --git a/ios/Widgets/Utils.swift b/ios/Widgets/Utils.swift
17-
index 76b2199..6cb52c3 100644
36+
index 76b2199c2d3f879463fed5d2bd49038b0428a2e7..6cb52c3de4ad9696bc0c51ad62401cce96f405e7 100644
1837
--- a/ios/Widgets/Utils.swift
1938
+++ b/ios/Widgets/Utils.swift
2039
@@ -125,6 +125,10 @@ func getLiveActivityEnvironment(for environment: EnvironmentValues, in context:
@@ -29,7 +48,7 @@ index 76b2199..6cb52c3 100644
2948
env["isActivityUpdateReduced"] = environment.isActivityUpdateReduced
3049
env["activityFamily"] = "\(environment.activityFamily)"
3150
diff --git a/ios/Widgets/WidgetLiveActivity.swift b/ios/Widgets/WidgetLiveActivity.swift
32-
index 4d135c4..dae4744 100644
51+
index 4d135c4e4eb1f846315654ed9d835a935d120d42..dae47445b27516fa2464a25b68bddc8f6dec3e1e 100644
3352
--- a/ios/Widgets/WidgetLiveActivity.swift
3453
+++ b/ios/Widgets/WidgetLiveActivity.swift
3554
@@ -19,53 +19,41 @@ struct LiveActivityAttributes: ActivityAttributes {
@@ -132,7 +151,7 @@ index 4d135c4..dae4744 100644
132151
LiveActivityBanner(context: context, nodes: nodes)
133152
} else if let node = nodes["banner"] as? [String: Any] {
134153
diff --git a/scripts/build-layout-registry.mjs b/scripts/build-layout-registry.mjs
135-
index d52a60e..fa9bd77 100644
154+
index d52a60e342c8e0a8a1d78f7174da5e60e6bd1c53..fa9bd77c5c04d459038a5b4a00e1391780b406fa 100644
136155
--- a/scripts/build-layout-registry.mjs
137156
+++ b/scripts/build-layout-registry.mjs
138157
@@ -154,6 +154,8 @@ function createLayoutRegistry(expectedWidgets, capturedLayouts) {
@@ -146,7 +165,7 @@ index d52a60e..fa9bd77 100644
146165
await main();
147166
}
148167
diff --git a/src/Widgets.types.ts b/src/Widgets.types.ts
149-
index 0770613..924fa00 100644
168+
index 07706139379384dae27befef4e3e5ae09d04a0db..924fa0029243664e369ce08c81e504b6300bfc7f 100644
150169
--- a/src/Widgets.types.ts
151170
+++ b/src/Widgets.types.ts
152171
@@ -107,6 +107,10 @@ export type LiveActivityEnvironment = {

‎pnpm-lock.yaml‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)