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

88 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Help Needed: Implementing a Countdown Timer Live Activity with Push Notifications
Notifying the Live Activity When Countdown is Complete: Once the countdown timer reaches zero, how do I notify the live activity? What is the best approach to ensure the live activity updates accurately and promptly? Handling App Suspension in the Background: When my app is in the background, it gets suspended. Should I set up a job queue on the backend to send an update push notification when the timer ends? Is there a more efficient way to handle this? Ensuring Timer Accuracy: Since this feature deals with time, I am concerned about the accuracy of the timer. How can I ensure the countdown timer remains accurate even when the app is not in the foreground? Any answers, insights, or guidance on these issues would be greatly appreciated. Thank you in advance for your help!
1
0
49
10h
Start live activity with push notification problem
Hey there, i implemented live activity in my app and iam trying to start the live activity from push notification, updates works fine even when the app is in background but starting the activity creating issue mostly on background and kill mode when i check the delivery of live activity on cloudkit console it says stored for device power considerations. anyone having the same issue ?
0
0
74
1d
Question about Live Activities Update Mechanism with Push Notification Permissions Turned Off
I have a question regarding the Live Activities feature introduced in iOS 16.1. According to the documentation, Live Activities can be updated via push notifications. However, I am curious to know if Live Activities can still receive updates via push notifications when push notification permissions are turned off for an app. Could you please clarify whether Live Activities updates are independent of the push notification permissions setting, and if so, how the update mechanism works in this scenario? Thank you for your assistance. Best regards,
0
0
81
1w
Questions about Live Activities
Our app is a time reporting service with various functions around that. The user checks in at work, checks out when they go home. We thought it'd be useful to provide a live activity to show how long they have worked for. There is also a couple of other cool things we could do that users would love, but i couldn't find definitive answers to the questions below. 1. We have a geofence-based function that checks the user in when they for example arrive at work, and check them out when they go home, so that they don't have to open the app. However, this means that we will need to start and end the live activity from within a geofence trigger. Is this possible? 2. It seems that the maximum time for a live activity is 8 hours? Sometimes people work for longer... How would we solve this? i would be fine with 12 since it would solve most cases. Is it possible somehow to go beyond 8 hours up to 12? If not, is there a callback that "8 hours are up!" so that i could do a final update on the live activity from a counter to "you started working at 09:04" 3. I have seen that some live activities have buttons. It would be neat if the user can check out via a button on the live activity. However, since we take location and call our servers when checking out, we need to be able to use both the locationmanager and make a network call from the live activity. Is this possible? Thanks in advance, Cheers
0
0
162
2w
ActivityKit pushTokenUpdates device support
I'm building a live activity with push token updates for my app as described in the documentation and implemented in the EmojiRangers example. The workflow is working fine for fairly new devices (iPhone > 13) - however, the asynchronous pushTokenUpdates sequence used to observe changes to the push token of a Live Activity is not getting triggered on some older devices (i.e. iPhone XR, iPad 8th Generation). Is there a minimum device version for this sequence? This is the code I'm using: "--------Task--------" gets printed, "--------PushTokenUpdate--------" does not (on older devices): do { let activity = try Activity.request( attributes: matchAttributes, content: .init(state: initialContentState, staleDate: nil), pushType: .token ) Task { print("--------Task--------") for await pushToken in activity.pushTokenUpdates { print("--------PushTokenUpdate--------") } } } catch { Logger().error("Error starting LiveActivity: \(String(describing: error))") }
1
0
155
2w
iOS LiveActivity dynamic island compile error
i'm struct dynamic island detail content dynamicIsland: { context in DynamicIsland { expandedContent(context: context) } compactLeading: { .... } compactTrailing: { ... } i want show different content based on context. private func expandedContent(context: ActivityViewContext<xxxx>)->DynamicIslandExpandedContent<some View> { if (context.state.style == 0) { return expandedControlContent1(context: context) } else if (context.state.style == 1) { return expandedControlContent2(context: context) } else { return expandedControlContent3(context: context) } } compiles error Function declares an opaque return type 'some View', but the return statements in its body do not have matching underlying types
0
0
172
Apr ’24
Live Activity Not working on Dynamic Island on TestFlight
Is something wrong with testing live activities on Dynamic Island in iOS 17? It works fine for devices without dynamic island. It's a timer countdown. Initially, it didn't show up on the iPhone 15 Pro, but after installing and reinstalling the app it showed up. But now, the timer freezes like it was freezing while it was being tested on a simulator. Is there something extra I should be doing for the Dynamic Island Display? P/S: The app uses only Live Activities without the widget.
1
0
234
Apr ’24
Starting Live Activity with push notification
Hello all, I am trying to start Live Activity from remote push notification with the new ActivityKit api. The documentation for starting live activity from a push notification says: When the system receives the ActivityKit push notification on a device, it starts a new Live Activity, wakes up your app, and grants it background run time to allow you to download assets that the Live Activity needs. While the system starts the new Live Activity and wakes up your app, you receive the push token you use for updates. To update and end the Live Activity, use this update push token as if you obtained it by starting a Live Activity from within your app. Is there any information on how to get access to the background runtime and the push token, when the app is in background when the Live Activity is started? I can get the pushToStartTokenUpdates if the app is already running and push notification arrives (and starts the Live Activity), but not in the background, which makes getting updates not possible unless user launches the app. Thanks!
2
0
278
Apr ’24
How to handle Push To Start Live Activity background run time
In iOS 17.2 we can start a live activity by push, and the document says: When the system receives the ActivityKit push notification on a device, it starts a new Live Activity, wakes up your app, and grants it background run time to allow you to download assets that the Live Activity needs. My problem is, in which callback can I be notified a live activity will be start by a push, so I can download some web contents such as images before the live activity be rendered.
2
0
322
1w
activitySystemActionForegroundColor(_:) modifier has no effect on action button
When setting a systemActounForegroundColor, no effect is seen on the lock screen when swiping away a Live Activity. Attempted with custom color assets and system colors, but maybe I am using it incorrectly? @available(iOS 16.2, *) struct DevicePollingLiveActivityWidget: Widget { typealias constants = DevicePollingLiveActivityConstants var body: some WidgetConfiguration { ActivityConfiguration(for: AlarmPollingActivityAttributes.self) { context in DevicePollingLockScreenView(deviceEvent: context.state.device) .activityBackgroundTint(.clear) .activitySystemActionForegroundColor(.white) } dynamicIsland: { context in DynamicIsland { // Expanded UI goes here. Compose the expanded UI through // various regions, like leading/trailing/center/bottom DynamicIslandExpandedRegion(.leading) {```
0
0
228
Apr ’24
Live Activity Stops Updating after iPhone Lock
My background audio app stops updating its Live Activity after the iPhone locks, and doesn't resume updating the activity after tapping the screen or even after FaceID unlocks the device (without opening the lock screen). My live activity requests a ContentState update & iOS updates the content for the activity as below: Task{ log.debug("LiveActivityManager.updateLiveActivity() with new ContentState") await liveActivity.update( ActivityContent(state:contentState, staleDate:nil) ) } Below what my log looks like: <<<<SWIPE LOCK SCREEN DOWN>>>> DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 <<<<PRESS LOCK BUTTON->Lock iPhone>>>> INFO: --------protectedDataWillBecomeUnavailableNotification-------- DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4 DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState <<<<LOOK AT & TAP LOCK SCREEN->Unlock iPhone without swiping up>>>> INFO: --------protectedDataDidBecomeAvailableNotification----------- DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState As shown in the log, normally iOS updates the content for my activity after my liveActivity.update request. This works fine in the Dynamic Island and when after switching apps and swiping down to see the lock screen without locking the phone. However, once I lock the phone, iOS stops updating the Live Activity content, and doesn't resume updates until after the app regains the foreground at least once. Has anyone else encountered this behavior? Is this a setting that I'm missing, or a bug?
5
0
675
Apr ’24
Pause Live Activity and Dynamic Island
How can i pause and resume Text((context.state.startTime.convertStringToDate() ?? Date()), style: .relative) and ProgressView( timerInterval: progressStartDate...Date().addingTimeInterval(TimeInterval((Int(earnTime) ?? 0) * 60)), countsDown: false, label: { EmptyView() }, currentValueLabel: { EmptyView() } ) I couldn't find any document to pause and resume activity
0
1
286
Feb ’24
Programmatic Access to ScreenTimeAPI
When is there going to be access to the ScreenTime API / ActivityKit API so that we can programmatically access Phone Pickups and Screen Time for applications? Currently, the information is limited to getting callbacks when a threshold is hit or approached, but we don't know really anything about what the threshold is, and we cannot do that in the background. It seems incredibly limited on scope. Any thoughts or estimates on when this might be possible? Thank you so much!
0
0
275
Feb ’24
Showing a countdown without seconds in ActivityKit
I'm using Text(targetDate, style:.relative) to show how a countdown of minutes until a given event. Unfortunately, this includes seconds, which takes unnecessary space and can get quite distracting when used on the dynamic island. There are many examples of apps that show estimates like "7 minutes" or "7 min" but how do they get the countdown to update? Are background updates reliable enough for this? Surely they don't send a push notification every minute to update the remaining time? Or is there some formatting option that I'm missing?
1
0
343
3w
Live Activity Text Style Issue in iOS Simulator's lock screen (iOS 17.2)
Environment: iOS Version: 17.2 iOS Simulator Version: 17.2 Xcode Version: 15.2 Device: iPhone 15 Pro Max App Target Version: iOS 17.2 Preconditions: App with Live Activity feature is installed. Device/Simulator is running iOS 17.2. Steps to Reproduce: Start the app and initiate a Live Activity with text styled as .timer. Lock the device screen or switch to the lock screen view in the iOS Simulator. Observe the Live Activity on the lock screen, noting the text style. Unlock the device. This time noting the .timer changed its style. The text style of the Live Activity remains consistent both on the lock screen and after unlocking the device, maintaining its .timer style throughout its lifecycle. Frequency: Occurs every time the steps are reproduced.
2
1
413
Jan ’24
LiveActivity crashs in iOS 14
LiveActivity is effective in ios16, but error reported only in ios14 Some error message reported from Xcode: Process: LiveExtension [20099] Path: my.app/PlugIns/LiveExtension.appex/LiveExtension libswiftCore.dylib swift_getAssociatedTypeWitness SwiftUI BodyAccessor.makeBody(container:inputs:fields:) SwiftUl closure #1 in WidgetGraph.init(rootBundle:)
0
0
261
Jan ’24
Is it possible to implement LiveActivities on an Swift/UIKit project?
All the documentation I've found so far is made for SwiftUI (I understand it was primarily designed for use with SwiftUI), but I'm still not able to find if there is even a way to do it. I tried to implement this very simple tutorial (https://www.youtube.com/watch?v=oloHJn1kj3w) and since it is done with SwiftUI, I tried to make a hybrid using UIHostingController, but had no luck. I made sure the configuration was set correctly, and I think it is because when I enter the app's settings (from the iPhone's settings app) the live activities button is there and turned on. Knowing how to do it would be awesome, but I would be satisfied with at least knowing if it is even possible, before wasting more time. Thanks.
0
0
335
Jan ’24