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

90 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Text view with .timer style expands too much in Live Activity
I'm implementing a Timer in my app and I want the countdown to show up as a Live Activity. It works, but I get a very weird expanding effect on the Text view. The screenshots below show the issue, I can't tell if it's a bug or if I'm doing something wrong. My goal is to shrink the live activity black area so that it's a smaller, more reasonable size. There's no reason for it to be as large as it is on the trailing side. The Live Activity code (very basic):   } dynamicIsland: { context in        } compactTrailing: { // Important bit is here            Text(Date(), style: .timer)        }    } Which renders like this, with a lot of space after the timer: Adding a background color shows the view is expanding: Text(Date(), style: .timer)     .background(.red) And if I replace the timer with a standard text view, then no issue: Text("Hello")        .background(.red) Getting out of live activities and showing a standard timer view, there is no expansion issue: struct TestView: View {     var body: some View {         Text(Date(), style: .timer)             .background(.red)     } } So... I'm stumped. Any advice is appreciated.
5
5
1.9k
Sep ’23
Tracking pushTokenUpdates and activityStateUpdates when app isn't running
Hello team, I'm looking for advice, please, about how to track updates to Activity.pushTokenUpdates and Activity.activityStateUpdates if my app isn't running. These two async sequences work great when my app is running, but that information is just as important if, for some reason, my app isn't running. In the WWDC video Update Live Activities with push notifications, the presenter says: when the system requests a new push token for an existing activity, your app will be given foreground runtime to handle it accordingly I was hoping that my app to be launched in the background... but I don't see how that would work unless there's a new call via the AppDelegate. Follow-up question... is there any documentation for the scenarios when a push token might be replaced for a live activity? Thank-you! Matthew
0
0
420
Sep ’23
Dynamic Island Height
I just want to know what is maximum height of dynamic island(expanded). When I just go through the documentation, it is showing 160pt. Here is url: https://developer.apple.com/design/human-interface-guidelines/live-activities#Specifications But as I observed, some of applications have more than 160pt height of dynamic island (expanded). If this is possible, how we can increase height of dynamic island. Even if we go through figma library, it is also showing more height https://www.figma.com/file/YVWH9fn64y36***6jYdks5/Dynamic-Island-iPhone-14-(Community)?node-id=0%3A1&mode=dev
0
0
867
Sep ’23
Content replace transition for SwiftUI?
In session wwdc2023-10194 Design dynamic Live Activities at 04:53, it mentioned that we should use 'content replace transition' for animating in and out graphic elements and text. The video shows some kind of animation combined with blurring and opacity changes. But I can't seem to find code for doing this in SwiftUI or UIKit. Does anyone know the API to achieve this? 🤔 Thank you for your help!
0
0
437
Sep ’23
Live Activity color issue in sleep mode
I have created a live activity that supports both light and dark mode, and are using the isLuminanceReduced environment variable to display the dark mode version on the always on display for the iPhone 14 Pro. However it seems that this variable is not true when I switch to the Sleep Mode focus state. Even though the Lock Screen gets just as dark, it still shows the light mode version of the activity, which results text being very hard to read. Any idea on what to do to display the dark mode version here? Or a way to have text that looks good in both light and dark screens?
5
3
1.7k
Sep ’23
How to integrate Live Activity into Objective C projects ?
I have a food delivery app similar to Uber Eat it was developed in Objective C now the requirement is to implement the Live activity for tracking the Active orders in live Activity. As i tried Live activity over the Swift it is working fine on all IOS Devices but when i implement that swift code into Objective C using all the standards by Bridging between Swift and Obj C copied the same code, There is no Error or Warning i am seeing in Live activity functionality in Objective C, but Live Activity UI can't seen on Lockscreen even i have checked in settings my app is showing that it supports Live Activity but no view. Can somebody help me out in that how to integrate live activity into Objective C project?
0
0
447
Sep ’23
how to use Live Acitivity in objective-c project?
I have a history objective-c project, and now i want to use Live Acitivity feature in that objc project. first i implement a live activity in swift project, and it works well on iphone devices. then i copy same codes from swift project to objective-c project, build and run on same iphone device, no error or warning generates, but Live Activity UI can't seen. can someone tell me how to fix it ? and only swift project can support Live Activity ?
1
1
459
Sep ’23
iOS 16.2 breaks ProgressView(timerInterval:countsDown:) on Dynamic Island or on Always-On Lock Screen
I used ProgressView to display a countdown progress bar in a Live Activity. However, I found that since iOS 16.2, ProgressView(timerInterval:countsDown:) does not update properly in the following situations. on Dynamic Island (either Expanded or CompactLeading/Trailing) on the Locked Screen, after the display is turned off (isLuminanceReduced == true) In these situations, the ProgressView for the countdown is always displayed at 100% and does not automatically update with the time. The problem only occurs in iOS 16.2. And it's confusing for users. Will it be fixed please?
1
2
1.5k
Aug ’23
Live Activity not working on iOS 16.6
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?
2
0
1.2k
Aug ’23
SwittUI.Text(timerInterval) display as xx:-- in Live Activity when Always-On Display is Active
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.
2
2
650
Aug ’23
Can Live Activities be updated via `activity.update` in extensions?
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
3
0
1.1k
Aug ’23
Is Timer disabled in Live Activity / Widget?
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
1
0
716
Aug ’23
How to dismiss live activity notification from Watch?
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])
0
0
674
Jul ’23
Dismiss Live Activities on App Termination
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?
3
1
2k
Jul ’23
Can't update Live Activity from app with ActivityKit when app is running in the background with background audio playing.
I had a timer app, it played white noise after starting the timer. so my app is running in the background with background audio, and the timer is perfect for display with live activity. However, when I test my code with a real device, I find calling await activity.update(using: contentState) when app is running in the background does not work at all. the code executes, but the live activity won't get updated. After some experiments, I find: if the app is running in the background with background location or Picture-in-picture mode, the app can update live activity when running in the background. If the app is running in the background with audio playing, it will work on simulator, but not on a real device. I submit a feedback: FB11683922 (Can't update Live Activity from app with ActivityKit when app is running in the background with background audio playing.) My code is like: func startLiveActivity() { // Prepare content state and attributes.     do {       self.activity = try Activity.request(attributes: activityAttributes, contentState: initialContentState) // Play audio so app can keep running in the background.       try playAudio()     } catch (let error) {       print("Error requesting Live Activity \(error.localizedDescription).")     }   } private func playAudio() throws {     try AVAudioSession.sharedInstance().setCategory(.playback, options: .mixWithOthers)     try AVAudioSession.sharedInstance().setActive(true)     if self.player == nil {       if let url = Bundle.main.url(forResource: "Forest", withExtension: "m4a") {         player = try AVAudioPlayer(contentsOf: url)         player?.numberOfLoops = -1       }     }     player?.stop()     player?.currentTime = 0     player?.play()   } after the timer stops, the code will execute, but the live activity won't get updated.   func updateActivity(){     Task {       if let activity = self.activity { // Prepare content state         await activity.update(using: contentState)       }     }   }
19
7
6.1k
Jul ’23