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.

ActivityKit Documentation

Posts under ActivityKit tag

88 Posts
Sort by:
Post not yet marked as solved
3 Replies
1.8k Views
I support Live Activities in my app, and am unable to dismiss Live Activities when the app gets closed from the background. Currently, I subscribe to the willTerminateNotification notification in order to perform actions when the app gets terminated. This guys triggered when the app gets terminated in the foreground. However, if it gets terminated from the background, it does not get triggered and my Live Activity stays after the app gets closed. How can I prevent this from happening?
Posted
by
Post not yet marked as solved
0 Replies
477 Views
I have implemented Live Activity in my app but have encountered occasional errors when a user attempts to start a Live Activity. According to Apple's documentation, the error thrown should be an ActivityAuthorizationError but this has not been my experience in testing. I have been able to cast it as an NSError or an Error, but not as an ActivityAuthorizationError or a LocalizedError. The code I've been using to start the Live Activity is pretty straightforward I think: do { let _ = try Activity.request(attributes: activityAttributes, contentState: initialContentState) as Activity<MyActivityAttributes> } catch { print(error.localizedDescription) // I would like to present an alert that provides a failure reason and recovery suggestion. } In my testing I can see the following error message: Error Domain=com.apple.ActivityKit.ActivityInput Code=1 "(null)" UserInfo={NSUnderlyingError=0x600003b17d20 {Error Domain=com.apple.ActivityKit.ActivityAuthorization Code=4 "(null)"}} The error shown in the UserInfo seems to be an ActivityAuthorization error, but I can only cast it as an NSError or Error. I would really like to provide the specific failure reason and recovery suggestion to users who experience a failure. Has anyone else come across this? Are there suggestions on how to actually get access to the ActivityAuthorizationError type? Thank you all.
Posted
by
Post not yet marked as solved
4 Replies
1.6k Views
I wanted to show count down timer in live activity. Since we can't use Timer in extensions, I used Text.init(timerInterval:pauseTime:countsDown:showsHours:) to show timer. But I need to show different text when the timer ends. How to achieve this behaviour?
Posted
by
Post not yet marked as solved
2 Replies
729 Views
How do you animate in live activities? I've seen apps been able to update around 1 fps. For example with a character looping a dance animation. How is this done? I don't think you can call Activity.update() every second. Also it wouldn't run in the background all the time anyway? Here's an example of Apple's own WWDC video with a bar animating https://imgur.com/a/yywW7a8
Posted
by
Post not yet marked as solved
1 Replies
754 Views
According to apple On devices that include an Always-On display, the system dims the screen to preserve battery life and renders Live Activities on the Lock Screen as if in Dark Mode. Use SwiftUI’s isLuminanceReduced environment value to detect reduced luminance on devices with an Always-On display and use images that look great for reduced luminance. But it seems to have no effect in live activities when displayed in the lock screen with AOD @Environment(\.isLuminanceReduced) var isLuminanceReduced Image("background1") .resizable() .aspectRatio(contentMode: .fit) .frame(height: 400) .offset(y:-40) .brightness(isLuminanceReduced ? -0.5 : 0)
Posted
by
Post not yet marked as solved
3 Replies
756 Views
Hello everyone, I'm developing a new feature that allows the user to keep track of a background upload through live activities. Im using the URLSessionTaskDelegate to keep track of the task progress and it works fine when the app is in foreground, but when the app goes to background, it stop after a few seconds. The upload still continues and Im able to receive updates on it's completion through the application(_ application: UIApplication, handleEventsForBackgroundURLSession but only through that. Also when I put the app back to foreground it updates to the correct progress so this is only happening in background. This is the URLSessionConfiguration I'm using: let config = URLSessionConfiguration.background(withIdentifier: "\(uploadBackgroundTaskIdentifier)") config.isDiscretionary = false config.allowsCellularAccess = true config.shouldUseExtendedBackgroundIdleMode = true config.sessionSendsLaunchEvents = true config.timeoutIntervalForResource = 28800 Does anyone knows how should I be able to keep track of the progress even when the app is in background?
Posted
by
Post not yet marked as solved
0 Replies
292 Views
Hi, i'm writing my first iOS Live Activity. Two questions about that: If "NSSupportsLiveActivitiesFrequentUpdates" is set, how many high-priority updates are permitted? I found no exact count. If the Live Activity is ended by user in the Lock Screen (swiping left and remove), how can I catch this to stop server-side update requests? Thanks!
Posted
by
Post not yet marked as solved
0 Replies
632 Views
If you update live activity with alertConfiguration: argument, iPhone shows a notification (or expands dynamic island): await runningActivity.update(content, alertConfiguration: .init(title: "Alert", body: "Done!", sound: .default)) Paired Watch presents a notification as well: I cannot find a way to dismiss that live activity notification from Watch. Is there a way to remove it similarly to UNUserNotifications? UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [notificationID])
Posted
by
Post marked as solved
1 Replies
609 Views
We notice when iPhone 14’s lock screen goes in Always-On mode, the countdown text in Live Activity: seconds part is displayed as -- minutes part only refresh every minute. Do you have any recommendations on how to improve it? For example, is there any system event or API to let our Live Activity know when lock screen enters/exit Always-On mode? If they are available, we would show something else to the user instead of xx:-- in Always-On lock screen.
Posted
by
Post not yet marked as solved
1 Replies
676 Views
In a Live Activity, we have use case to show some countdown for the user o finish some tasks before a deadline. When the deadline reaches, we want to show a different message. We create a timer in our Live Activity codes, listen to it and want to change the text when the timer fires. But, the timer never fires. We write another simple codes to verify: We didn’t see the countdown effect. We are wondering if Timer is disabled in Live Activity, so it never fires or State variable is disabled, so even Timer fires and changes State variable’s value, View cannot pick up the new State variable’s value
Posted
by
Post marked as solved
1 Replies
1k Views
I'm trying to build a live activity with the new iOS 17.0 interactivity, and I want a button on the live activity to update the live activity when clicked (e.g. start a timer). This works fine with a widget, but with live activities it doesn't seem like the activity view gets refreshed instantly. As a workaround, I tried putting the activity.update code in the button's intent's perform method. This doesn't seem to work as the intent gets executed from the widget extension, which seems to always have an empty activities (link) array. Question: Is activity.update only meant to be called from the app (either foregrounded or in a background task), or should it also be possible to be called in the WidgetExtension itself? Ideally I'd be able to avoid using push notifications, which seems overkill for e.g. just at timer. Related thread: Changing the live activity without push notification
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
Hey all, I was testing my app on my iPhone that just updated to 16.6. For some reason, when I request to show an Activity, the request goes through, tells me that my live activity is currently running (w/o any errors) yet won't show on the lock screen. When I tested on the Simulator, which is running 16.4, I am able to see the Live Activity perfectly fine. Has there been some change that would prevent me from seeing the Live Activity now?
Posted
by