fix(mobile): an expired Live Activity no longer leaves a second card (#15254)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
65731f986b
commit
77823bd102
2 files changed
+28
-9
No files matched your search
@@ -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 @@ index c9f4dfe..dc0792e 100644
|
||||
/**
|
||||
* 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(
|
||||
diff --git a/ios/Widgets/Utils.swift b/ios/Widgets/Utils.swift
|
||||
index 76b2199..6cb52c3 100644
|
||||
index 76b2199c2d3f879463fed5d2bd49038b0428a2e7..6cb52c3de4ad9696bc0c51ad62401cce96f405e7 100644
|
||||
--- a/ios/Widgets/Utils.swift
|
||||
+++ b/ios/Widgets/Utils.swift
|
||||
@@ -125,6 +125,10 @@ func getLiveActivityEnvironment(for environment: EnvironmentValues, in context:
|
||||
@@ -29,7 +48,7 @@ index 76b2199..6cb52c3 100644
|
||||
env["isActivityUpdateReduced"] = environment.isActivityUpdateReduced
|
||||
env["activityFamily"] = "\(environment.activityFamily)"
|
||||
diff --git a/ios/Widgets/WidgetLiveActivity.swift b/ios/Widgets/WidgetLiveActivity.swift
|
||||
index 4d135c4..dae4744 100644
|
||||
index 4d135c4e4eb1f846315654ed9d835a935d120d42..dae47445b27516fa2464a25b68bddc8f6dec3e1e 100644
|
||||
--- a/ios/Widgets/WidgetLiveActivity.swift
|
||||
+++ b/ios/Widgets/WidgetLiveActivity.swift
|
||||
@@ -19,53 +19,41 @@ struct LiveActivityAttributes: ActivityAttributes {
|
||||
@@ -132,7 +151,7 @@ index 4d135c4..dae4744 100644
|
||||
LiveActivityBanner(context: context, nodes: nodes)
|
||||
} else if let node = nodes["banner"] as? [String: Any] {
|
||||
diff --git a/scripts/build-layout-registry.mjs b/scripts/build-layout-registry.mjs
|
||||
index d52a60e..fa9bd77 100644
|
||||
index d52a60e342c8e0a8a1d78f7174da5e60e6bd1c53..fa9bd77c5c04d459038a5b4a00e1391780b406fa 100644
|
||||
--- a/scripts/build-layout-registry.mjs
|
||||
+++ b/scripts/build-layout-registry.mjs
|
||||
@@ -154,6 +154,8 @@ function createLayoutRegistry(expectedWidgets, capturedLayouts) {
|
||||
@@ -146,7 +165,7 @@ index d52a60e..fa9bd77 100644
|
||||
await main();
|
||||
}
|
||||
diff --git a/src/Widgets.types.ts b/src/Widgets.types.ts
|
||||
index 0770613..924fa00 100644
|
||||
index 07706139379384dae27befef4e3e5ae09d04a0db..924fa0029243664e369ce08c81e504b6300bfc7f 100644
|
||||
--- a/src/Widgets.types.ts
|
||||
+++ b/src/Widgets.types.ts
|
||||
@@ -107,6 +107,10 @@ export type LiveActivityEnvironment = {
|
||||
|
||||
Generated
+4
-4
Reference in new issue
Block a user