ActivityKit

RSS for tag

Help people keep track of tasks and events that they care about with Live Activities on the Lock Screen, the Dynamic Island, and in StandBy.

Posts under ActivityKit tag

133 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Dynamic island not displaying UI views
i finally got previews for dynamic island to work and I'm just trying to first work on adding a static UI elements to my dynamic island like i did for my live screen live activity, but my dynamic island view is showing up totally empty, if i add my app icon image to the compact leading closure, it doesn't appear, if i ad text to an expanded region closure it doesn't appear. am really stuck on this and would approeciate the help. var body: some View { Image("dynamicrep") .resizable() .scaledToFit() .clipShape(.circle) } } struct DynamicRepLiveActivity: Widget { var body: some WidgetConfiguration { ActivityConfiguration(for: DynamicRepAttributes.self) { context in VStack { HStack(spacing: 257) { Text("from \(context.attributes.titleName ?? "no title")") .fontWeight(.light) .font(.system(size: 16)) .foregroundStyle(Color.gray) Circle() .frame(width: 53, height: 50) .foregroundStyle(Color.gray).opacity(0.23) .overlay { Image("mmicon") } } .frame(maxWidth: 500, maxHeight: 210) Spacer() Text("\(context.attributes.contentBody ?? "no content")") } .activityBackgroundTint(Color.cyan) .activitySystemActionForegroundColor(Color.black) .frame(width: 500, height: 300) } dynamicIsland: { context in DynamicIsland { // Expanded UI goes here. Compose the expanded UI through // various regions, like leading/trailing/center/bottom DynamicIslandExpandedRegion(.leading) { Text("from \(context.attributes.titleName ?? "no title")") } DynamicIslandExpandedRegion(.trailing) { Circle() } DynamicIslandExpandedRegion(.bottom) { Text("\(context.attributes.contentBody ?? "no content")") } } compactLeading: { AppLogo() } compactTrailing: { Text("") //empty for now } minimal: { Text("hello") //empty for now } .widgetURL(URL(string: "MuscleMemory.KimchiLabs.com")) .keylineTint(Color.white) } } }
0
0
28
5d
LiveActivity start via APNs not working
I am trying to issue the "start" APNs push notification to start a live activity for my iOS app. The notification appears to send correctly, there is no error message, but the live activity never appears for any of my users (users are in TestFlight). In addition to issuing the APNs commands from my server, I have also tried using the CloudKit Push Notification Console to manually generate a "start" notification. It submits correctly but the live activity never starts. I have also checked the Console app to watch the device logs and see if iOS is rejecting/throttling the live activity but I don't see any activity related to the start message at all. Here are some details: App bundle ID: `com.penzu.moodmoji` APNs topic: `com.penzu.moodmoji.push-type.liveactivity` APNs push type: `liveactivity` Recent apns-id: `7b633309-b7fd-4163-b620-776efa04f315` APNs payload: { "aps": { "timestamp": 1742651625, "event": "start", "content-state": { "totalDays": 7, "currentDay": 2, "progress": 0.29, "status": "ACTIVE", "reportReady": false }, "attributes-type": "GoalActivityAttributes", "attributes": { "totalDays": 7, "currentDay": 2, "progress": 0.29, "status": "ACTIVE", "reportReady": false }, "alert": { "title": "It's day 2!", "body": "Don't forget to record every time you feel anxious today." } } } I can confirm that LiveActivities started by the iOS app with ActivityKit work correctly, and the app does appear to be receiving pushToStartTokenUpdates: struct GoalActivityAttributes: ActivityAttributes, Sendable { struct ContentState: Codable & Hashable, Sendable { let totalDays: Int let currentDay: Int let progress: Double let status: String let reportReady: Bool } let goal: SimpleGoal } for await nextStartToken in Activity<GoalActivityAttributes>.pushToStartTokenUpdates { // send nextStartToken to server... } The app I'm testing with is in TestFlight, using the production APNs environment.
1
0
32
5d
Symbol not found: NSUserActivityTypeLiveActivity and WidgetCenter.UserInfoKey.activityID
The app I'm working on has iOS 16.0 as target. Recently Live Activities support was added, but then it started crashing when running on iOS 16.0 devices. After some investigation, I've found that the culprit was the presence of NSUserActivityTypeLiveActivity and WidgetCenter.UserInfoKey.activityID, even though they were inside an @available(iOS 17.2, *) block. If I comment these two variables, the app work as expected. I've also tried adding #if canImport(ActivityKit) around the code, but without success. But if the @available isn't working, how can I prevent this? It looks like a bug, since the documentation says that NSUserActivityTypeLiveActivity is supported but iOS 14.0+, but I'm pretty sure it was introduced on 16.1. This is the only output I get with the crash: dyld[66888]: Symbol not found: _$s9WidgetKit0A6CenterC11UserInfoKeyV10activityIDSSvgZ Referenced from: <D6EFF120-2681-34C1-B261-8F3F7B388238> /Users/<redacted>/Library/Developer/CoreSimulator/Devices/8B5B4DC9-3D54-4C91-8C88-E705E851CA0F/data/Containers/Bundle/Application/DB6671FF-CB07-4570-BD63-C851D94FAF29/<redacted>.app/<redacted>.debug.dylib Expected in: <C5E72BB5-533F-3658-A987-E849888F4DFC> /Library/Developer/CoreSimulator/Volumes/iOS_20A360/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 16.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/WidgetKit.framework/WidgetKit
0
0
29
1w
Push Live Activity not showing up
This is in an iOS Simulator running iOS 18.2 I send a start live activity push notification from the Push Notifications Console on icloud.developer.apple.com. When checking the console.log output it seems to receive the message, yet the activity does not appear in the dynamic island. (the app is backgrounded when I test this) Can anyone tell me why it's not showing? Starting the same activity from within the app using Swift code works fine. Here is the console.app output: default 11:01:59.060954+0100 apsd <APSConnectionServer: 0x104207b80; development/com.apple.aps.sessioncore.PushNotifications.dev/liveactivitiesd 0>: Sending push to client. UUID: (null) default 11:01:59.061012+0100 apsd Dispatching high priority message on server: <APSConnectionServer: 0x104207b80; development/com.apple.aps.sessioncore.PushNotifications.dev/liveactivitiesd 0> default 11:01:59.061770+0100 apsd Looking up connection on peer: 4304b50 found <APSConnectionServer: 0x104207b80; development/com.apple.aps.sessioncore.PushNotifications.dev/liveactivitiesd 0> default 11:01:59.062283+0100 liveactivitiesd APSXPCDeliverMessageEvent: Created APSIncomingMessage. UUID: (null) default 11:01:59.062642+0100 liveactivitiesd <APSConnection: 0x600003d18000> Delivering message from apsd: <APSIncomingMessage: 0x600000c2e9a0> 2897852514 com.****.****.push-type.liveactivity default 11:01:59.062763+0100 liveactivitiesd <APSConnection: 0x600003d18000> Delivering message from apsd. UUID: (null) default 11:01:59.063374+0100 liveactivitiesd <APSConnection: 0x600003d18000> making delegate (<SessionPushNotifications.APSPushConnection: 0x600000227460>) calls to deliver message 2897852514 { aps = { alert = { "loc-key" = "recording_started_message"; "title-loc-key" = "recording_started_title"; }; attributes = { isRecording = 1; }; "attributes-type" = SWAutomaticTripRecorderActivityAttributes; "content-state" = { distance = 0; }; event = start; timestamp = 1742374701; }; } for topic com.****.****test.push-type.liveactivity default 11:01:59.063440+0100 liveactivitiesd <APSConnection: 0x600003d18000> calling <SessionPushNotifications.APSPushConnection: 0x600000227460> connection:didReceiveIncomingMessage: default 11:01:59.063740+0100 liveactivitiesd Acquiring keep-alive with reason: Received message default 11:01:59.063785+0100 liveactivitiesd Keep-alive reasons: ["Received message": 1] default 11:01:59.063803+0100 liveactivitiesd <APSConnection: 0x600003d18000> returned from <SessionPushNotifications.APSPushConnection: 0x600000227460> connection:didReceiveIncomingMessage: default 11:01:59.063883+0100 liveactivitiesd <APSConnection: 0x600003d18000> responding with an ack for message with guid E19D7D04-12A0-4F1B-B33C-F6BF57EE2EFF default 11:01:59.063921+0100 liveactivitiesd <APSConnection: 0x600003d18000> responding with an ack. UUID: (null) default 11:01:59.063996+0100 apsd Looking up connection on peer: 4304b50 found <APSConnectionServer: 0x104207b80; development/com.apple.aps.sessioncore.PushNotifications.dev/liveactivitiesd 0> default 11:01:59.064019+0100 apsd <APSUserCourier 0x100f052a0 development 0> informed that <APSConnectionServer: 0x104207b80; development/com.apple.aps.sessioncore.PushNotifications.dev/liveactivitiesd 0> acknowledges incoming message with guid E19D7D04-12A0-4F1B-B33C-F6BF57EE2EFF tracingUUID (null) default 11:01:59.064063+0100 liveactivitiesd Received message: topic: Topic(unsuffixed: "com.****.****test"); channelID: nil; token: Optional(128 bytes); eventType: start(SessionPushNotifications.IncomingMessage.EventType.StartParameters(attributesType: "SWAutomaticTripRecorderActivityAttributes", attributesData: 20 bytes, inputs: [])) for environment: development default 11:01:59.064198+0100 liveactivitiesd Received push event for com.****.****test::pushToStart default 11:01:59.064232+0100 liveactivitiesd Adding push-to-start budget for com.****.****test::pushToStart default 11:01:59.064273+0100 liveactivitiesd Acquiring keep-alive with reason: Database default 11:01:59.064296+0100 liveactivitiesd Keep-alive reasons: ["Database": 1, "Received message": 1] default 11:01:59.064313+0100 liveactivitiesd Acquiring keep-alive with reason: Database default 11:01:59.064330+0100 liveactivitiesd Keep-alive reasons: ["Database": 2, "Received message": 1] default 11:01:59.064342+0100 liveactivitiesd Reduced budget for com.****.****test::pushToStart to: 9 default 11:01:59.064358+0100 liveactivitiesd Topic com.****.****test.push-type.liveactivity has remaining budget for pushToStart of 9 default 11:01:59.064369+0100 liveactivitiesd Topic com.****.****test.push-type.liveactivity has not used any budget for activity default 11:01:59.064436+0100 liveactivitiesd Scheduling wake to re-evaluate push subscription budgets at 2025-03-19 11:01:59 +0000 default 11:01:59.064547+0100 liveactivitiesd Earliest nonwaking date from task "Push server budget timeout expiration": 2025-03-19T12:01:59+01:00, finalWakeTarget: 2025-03-19T12:01:59+01:00 3599.999696 default 11:01:59.064593+0100 liveactivitiesd Earliest waking date from task "Push server budget timeout expiration": 2025-03-19T12:01:59+01:00, finalWakeTarget: 2025-03-19T12:01:59+01:00 3599.999651 default 11:01:59.064620+0100 liveactivitiesd Scheduling nonwaking task for: 2025-03-19T12:01:59+01:00 in 3599.999622s default 11:01:59.064659+0100 liveactivitiesd Scheduling waking task for: 2025-03-19T12:01:59+01:00 in 3599.999584s default 11:01:59.064671+0100 liveactivitiesd Acquiring keep-alive with reason: wake scheduling default 11:01:59.064692+0100 liveactivitiesd Keep-alive reasons: ["Database": 2, "Received message": 1, "wake scheduling": 1] default 11:01:59.064734+0100 liveactivitiesd Scheduling waking task for adjusted date: 2025-03-19T12:01:59+01:00 in 3599.999508s default 11:01:59.064768+0100 liveactivitiesd xpc_activity_register: com.apple.sessionkit.wake, criteria: dictionary default 11:01:59.064843+0100 liveactivitiesd Received pushToStart notification for com.****.****test::pushToStart default 11:01:59.064955+0100 liveactivitiesd Keep-alive reasons: ["Database": 2, "Received message": 1] default 11:01:59.064979+0100 liveactivitiesd Publishing event: timestamp: 2025-03-19 08:58:21 +0000; activityIdentifier: F432AB2F-1799-4437-B54B-6D9D70A0B260; eventType: start(SessionPushNotifications.PushEvent.EventType.ActivityStartParameters(attributesType: "SWAutomaticTripRecorderActivityAttributes", attributesData: 20 bytes, contentSourceRequests: [ActivityKit.ActivityContentSource.Request.push(request: ActivityKit.PushActivityContentSource.Request.push, target: ProcessDescriptor.Request("com.****.****test")), ActivityKit.ActivityContentSource.Request.process(target: ProcessDescriptor.Request("com.****.****test"))]))
1
0
17
1w
How can you tick between live activities?
I have been watching the following moment from wwdc (Design dynamic Live Activities): https://developer.apple.com/videos/play/wwdc2023/10194/?time=728 It suggest that you should 'tick' between multiple live activities of your app: When you want to show multiple sessions for your app going on at once, consider ticking between the display of them to continue to give users an eye on everything that’s going on. How can I tick between them? More specifically how can I do that when my app is in the background?
0
1
126
1w
How to properly share code between launch in background and launch in foreground?
I've been reading this question: https://developer.apple.com/forums/thread/701945 and watching the videos on background tasks But can't arrive to a concrete solution. Q1: Are there any tips (or sample app) on how to handle a launch in background in a streamlined way? How to have a shared code that is ran for both 'launch in background' & 'launch in foreground'? Specifically the case I'm talking about is: You set up some observance of some OS callback at a Foo screen of your app. Example app should request and then send push-to-start live activity tokens to server. Or setup location tracking. App is then suspended and then later terminated but is eligible for relaunch App is then launched in background because it has requested a push-to-start live activity token or an update for location tracking. User DOES NOT go back to screen Foo. So at this point app is no longer tracking / listening to updates for token update or location changes. How should I architecture my code for this? I'm trying to see if there's a an approach where I can avoid having multiple places in code where I do the same thing. Currently what I'm doing is as such: Q2: Is it then correct to say that anytime you've launched your app, whether it's in foreground or background then you must immediately match 'all observations done by the previous app launch'? Like store items in UserDefaults and upon launch retrieve them and do: handleGeneralAppLaunchFlow() // ALSO if defaults.contains("didLastLaunchSetupLiveActivtiyTokenObservance") { for await ptsToken in Activity<EmojiRangers> .pushToStartTokenUpdates { ... } } if defaults.contains("didLastLaunchSetupLocationTracking") { locationManager = CLLocationManager() locationManager?.delegate = itsDelegate locationManager?.allowsBackgroundLocationUpdates = true locationManager?.showsBackgroundLocationIndicator = true locationManager?.startUpdatingLocation() } // Other checks for prior observance setup Q3: Actually I think even if app is launched in foreground then because you may not end up at screen Foo again, then you must setup things regardless of app state and just based on prior observations set. Right? Q4: And then later if the user ever made it again to screen Foo, then we just skip the re-do of the observance, or maybe to just keep things simple, we'd just redo without over-engineering things? I tried to mark my questions with Q1- Q4.
1
0
128
1w
Start multiple Live Activities in the perform() of App Intents
In my case, when two functions that start each Live Activity(not connected each other) are performed in LiveActivityIntent's perform(), it seems that only one will start. (It's the same to start independently with two Task{}) And, set one to 'opensIntent' and separate it by opening another LiveActivityIntent, the result is same. Also, every time I tap the Intent directly in the shortcut app, one activity will end within a matter of seconds, even if there are two for a while. But, If openAppWhenRun to true, it seem to works without any problems. I would appreciate it if you could give me a tip to fix this problem.
0
0
107
2w
Broadcast Push Notifications - Update ignored
I want to update my lockscreen LiveActivity via Broadcast Push Notification, but updating always fails - but ending always works. Payload with "update" is completely ignored: {"aps":{"timestamp":1685952000,"event":"update","content-state":{"currentSlotName":"Debug1","nextSlotName":"Debug2"}}} Same payload with "end" works, the view is refreshed with the new content-state: {"aps":{"timestamp":1685952000,"event":"end","content-state":{"currentSlotName":"Debug1","nextSlotName":"Debug2"}}} Via the MacOS Console I am able to see that both events happen to end up on the device. I am sending these Broadcast Push Notifications via Apple's Push Notifications Console.
2
0
203
2w
Custom watchOS Live Activity
I have followed this video on implementing a custom view for the watchOS 11 Smart Stack Live Activities. However, the UI of my iOS app keeps showing up on the watchOS. `struct widgetLiveActivity: Widget { @Environment(.activityFamily) var activityFamily var body: some WidgetConfiguration { ActivityConfiguration(for: widgetAttributes.self) { context in switch activityFamily { case .small, _: Text("WatchOS UI") case .medium: Text("iOS UI") .activitySystemActionForegroundColor(Color.black) } dynamicIsland: { context in ... } .supplementalActivityFamilies([.small, .medium]) } }`
1
0
236
2w
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!
3
0
271
2w
Push-to-Start Live Activity Background Task Issue After App Termination
Desired Behavior I want the app to be able to handle multiple Push-to-Start notifications even when it is completely terminated. Each Live Activity should: Be successfully displayed upon receiving a Push-to-Start notification. Trigger background tasks to send its update token to the server, regardless of the time interval between notifications. Problem I am facing an issue with iOS Live Activities when using Push-to-Start notifications to trigger Live Activities in an app that has been completely terminated. Here’s the detailed scenario: When the app is completely terminated and I send the first Push-to-Start notification: The Live Activity is successfully displayed. didFinishLaunchingWithOptions` is triggered, and background tasks execute correctly, including sending the update token to the server. When I send consecutive Push-to-Start notifications in quick succession (e.g., within a few seconds or minutes): Both notifications successfully display their respective Live Activities. Background tasks are executed correctly for both notifications. However, when there is a longer interval (e.g., 10 minutes) between two Push-to-Start notifications: The first notification works perfectly—it displays the Live Activity, triggers didFinishLaunchingWithOptions, and executes background tasks. The second notification successfully displays the Live Activity but fails to execute any background tasks, such as sending the update token to the server. My HypothesisI suspect that iOS might impose a restriction where background runtime for Push-to-Start notifications can only be granted once within a certain time frame after the app has been terminated. Any insights into why this issue might be occurring or how to ensure consistent background task execution for multiple Push-to-Start notifications would be greatly appreciated!
1
0
222
2w
App Clip Closes Before SKOverlay Can Show “Open” Button When Live Activity Is Involved
I have an App Clip that uses SKOverlay.AppClipConfiguration to install the full app. Before I added a Live Activity call (Activity.request), the user could see “Install,” then “Open.” Now, once “Get” is tapped, the Clip immediately closes—no “Open” button appears. If I remove the Live Activity code, it works again. I’ve confirmed that parent/child entitlements match, and tested via TestFlight. Is there a known issue or recommended workaround for combining SKOverlay + Live Activities in an App Clip so it doesn’t dismiss prematurely? Any insights are appreciated! Note live activity is for App Clip only.
1
0
227
3w
Live Activity don't show properly in Apple Watch
I'm facing an issue with Live Activity on the Apple Watch. I followed all the configurations outlined in Apple's official documentation, but during testing, I noticed inconsistent behavior. Some devices can display the Live Activity on the Apple Watch without any issues, while others can only see it on the iPhone, even though they are running the same system version. I've already checked the permissions, and everything is set up correctly, but I still haven't found what might be causing this difference. Has anyone experienced something similar or has any debugging suggestions?
0
0
198
3w
Live Activity ending immediately after being created
I'm seeing a Live Activity that's ended almost immediately after I'm creating it. I'm not ending the activity in my code, so something is happening at the system level. iOS version is 18.3.1. Looking at the logs for liveactivitiesd, I see that it was successfully created: default 12:57:34.837266-0800 liveactivitiesd Created activity: 22713DF6-E853-4B34-85FA-CD08D8FCA91B default 12:57:34.837639-0800 liveactivitiesd Starting activity: identifier: 22713DF6-E853-4B34-85FA-CD08D8FCA91B; createdDate: 2025-02-17 20:57:34 +0000; state: active; deviceIdentifier: local; resolvedContentSources: [ActivityKit.ActivityContentSource.process(target: <snip>), ActivityKit.ActivityContentSource.sync]; lastUpdateDate: 2025-02-17 20:57:34 +0000; endingOptions: nil default 12:57:34.858701-0800 liveactivitiesd Activity did start 22713DF6-E853-4B34-85FA-CD08D8FCA91B But then moments later, it's immediately ended: default 12:57:34.933963-0800 liveactivitiesd Ending activity 22713DF6-E853-4B34-85FA-CD08D8FCA91B for XPC participant content source <private> default 12:57:34.933983-0800 liveactivitiesd Stopping activity: 22713DF6-E853-4B34-85FA-CD08D8FCA91B default 12:57:34.934019-0800 liveactivitiesd Activity: identifier: 22713DF6-E853-4B34-85FA-CD08D8FCA91B; createdDate: 2025-02-17 20:57:34 +0000; state: active; deviceIdentifier: local; resolvedContentSources: [ActivityKit.ActivityContentSource.process(target: <snip>), ActivityKit.ActivityContentSource.sync]; lastUpdateDate: 2025-02-17 20:57:34 +0000; endingOptions: nil should be discarded now default 12:57:34.934442-0800 liveactivitiesd Activity discarded: 22713DF6-E853-4B34-85FA-CD08D8FCA91B Again, I'm not ending this activity in my code. I'll occasionally see this happen in my app, and the only solution I've found is to restart my device. Afterwards, everything seems fine. Is this a bug?
0
1
286
Feb ’25
Custom `DiscreteFormatStyle` in live activities
Hello, I'm trying to display some Duration in a live activity using a custom format, with the goal of displaying a match time (only minutes) as, e.g. 33', 45' (+2), etc. For that purpose, I'm using a TimeDataSource&lt;Duration&gt;, so that it also updates automatically given a starting point. I've implemented my custom FormatStyle, trying to somehow mimic the existing UnitsFormatStyle (which perfectly works with live activities) but just changing the format. I've added conformance to DiscreteFormatStyle, and code-wise everything seems to be ok (if I've understood things correctly). It compiles and it even works as expected in a playground. However, when trying to use it within the live activity, I'm getting these cryptic errors in the Console.app, and the live activity just turns into a view with placeholders Failed to fetch view from archive at index 12: SwiftUI.AnyCodable&lt;SwiftUI.(unknown context at $1d47f6af0).SafelyCodableRequirement&gt;.(unknown context at $1d47fe410).Errors.noType(mangledName: "7SwiftUI18TimeDataFormattingO10ResolvableVy_AA0cD6SourceVAAE15DurationStorageOys0H0V_GAK28BlickLiveActivitiesExtensionE16MatchFormatStyleVG") [624AEC37-13D9-4927-9F41-C3092B61E214] Failed to return view entry from archive for view model with tag listItem with error: SwiftUI.AnyCodable&lt;SwiftUI.(unknown context at $1d47f6af0).SafelyCodableRequirement&gt;.(unknown context at $1d47fe410).Errors.noType(mangledName: "7SwiftUI18TimeDataFormattingO10ResolvableVy_AA0cD6SourceVAAE15DurationStorageOys0H0V_GAK28BlickLiveActivitiesExtensionE16MatchFormatStyleVG") Are there any limitations when it comes to live activities and these custom formatters? This whole error doesn't make sense, since I'm only aiming to update every minute, which should just be fine, the same thing I get with the UnitsFormatStyle. For reference, this is my playground, which just works as expected: import Foundation import SwiftUI import PlaygroundSupport extension Duration { struct MatchFormatStyle: DiscreteFormatStyle, Sendable { let periodLength: Int let overtime: Int func format(_ value: Duration) -&gt; String { let (seconds, _): (Int64, Int64) = value.components let minutes: Int = Int(seconds) / 60 let current: Int = periodLength + minutes + overtime if current &gt; periodLength { return "\(periodLength)' (+\(current - periodLength))" } else { return "\(current)'" } } func discreteInput(before input: Duration) -&gt; Duration? { let (seconds, _): (Int64, Int64) = input.components let minutes: Int64 = seconds / 60 - 1 return Duration(secondsComponent: minutes * 60, attosecondsComponent: .zero) } func discreteInput(after input: Duration) -&gt; Duration? { let (seconds, _): (Int64, Int64) = input.components let minutes: Int64 = seconds / 60 + 1 return Duration(secondsComponent: minutes * 60, attosecondsComponent: .zero) } } } extension FormatStyle where Self == Duration.MatchFormatStyle { static func matchTime(currentTime: Int, periodLength: Int) -&gt; Duration.MatchFormatStyle { return Duration.MatchFormatStyle(periodLength: periodLength, overtime: max(currentTime - periodLength, .zero)) } } extension TimeDataSource&lt;Date&gt; { static func matchDuration(for currentTime: Int, periodLength: Int) -&gt; TimeDataSource&lt;Duration&gt; { let minutesAhead: Double = Double(max(periodLength - currentTime + 1, .zero)) return TimeDataSource&lt;Date&gt;.durationOffset(to: Date.now.addingTimeInterval(minutesAhead * 60)) } } struct FooView: View { let currentTime: Int = 36 let periodLength: Int = 45 var body: some View { Text( TimeDataSource&lt;Date&gt;.matchDuration(for: currentTime, periodLength: periodLength), format: .matchTime(currentTime: currentTime, periodLength: periodLength) ) .frame(width: 400, height: 200) .font(.system(size: 50)) } } // Present the view controller in the Live View window PlaygroundPage.current.setLiveView(FooView()) Any hints or suggestions are welcome, many thanks in advance.
3
1
305
Feb ’25
Background App wake up when Live Activity Offline Push Arrived not reliable
we have three problem when using the push notification on Live Activity. 1. What is the specific callback strategy for the activityUpdates property in ActivityKit? We found that in actual user scenarios, there is a probability that we may not receive callbacks. From the community experience, there are some resource optimization strategies that do not perform callbacks. From this perspective, the explanation is kind of vague. Is there any clear feedback to understand why callbacks are performed/not performed? 2.what is the specific description of the wake-up strategy, when background app receive Live Activity offline start Push? From community experience, we can see that the system may wake up for a duration of 0-30s due to resource optimization strategies, or not wake up/not deal with it. Is there an official description of the wake-up strategy? or we also have to follow this description: Wake up of apps using content-available pushes are heavily throttled. You can expect 1-2 wakeup per hour as a best case scenario in the hands of your users. so this cannot be assumed to be a reliable wake-up on demand mechanism for an app. 3 How can we determine user have selected (allow or always allow) of the Live Activity permission? When we use real-time activity offline push, there are two system prompts in iOS: the first prompt : allow and disallow real-time activity the second prompt : always allow and disallow Is there an interface that can directly determine which permission the user has chosen (allow/always allow)? (By the way, we can get disallow status). At present, we haven't seen any interface in the official documentation/interface that can determine (allow/always allow). The difference here will affect the generation of Update Token. Without Update Token, we can not update our activity instance.
0
1
489
Feb ’25
Live Activity without Dynamic Island
Is it possible to display a live activity on the lock-screen without a dynamic island? Or at least without expanding the dynamic island more than just for a small icon? struct SomeWidgetLiveActivity: Widget { var body: some WidgetConfiguration { ActivityConfiguration(for: SomeAttributes.self) { context in } dynamicIsland: { context in DynamicIsland { DynamicIslandExpandedRegion(.leading) { // Seems to be mandatory, any way around it? } } compactLeading: { } compactTrailing: { } minimal: { } } I couldn't quite find a way. Thank you
0
0
355
Jan ’25