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
1 Replies
1.1k Views
Some users couldn't receive push notifications, and APNS returned a 'DeviceTokenNotForTopic' error. Upon validation using Apple's tool, I found that some tokens are identified as VoIP push tokens, and some as Live Activity (LA) push tokens. When attempting to send a normal alert push using these VoIP/LA push tokens, it didn't work and returned a 'DeviceTokenNotForTopic' error. These tokens were obtained from Apple's delegate function 'didRegisterForRemoteNotificationsWithDeviceToken.' It's unexpected to receive VoIP/LA push tokens from this event, but this issue is occurring, and I've observed it specifically in iOS 17 users. This problem is not universal and is happening only for some users. Please take note that our app support VoIP Push, Live Activity Push and Normal Push notification. Could this be an iOS 17 bug? Any advice on this matter would be appreciated. Thanks.
Posted
by
Post not yet marked as solved
2 Replies
511 Views
In iOS 17.2+, we have a new feature that lets you use a push notification to start a Live Activity. The docs mention this: While the system starts the new Live Activity and wakes up your app, you receive the push token you use for updates. How exactly does this work? I don’t see any listeners/delegate methods that trigger when you receive a start event. Since I need to extract the push tokens from a specific instance, how do I get that instance? I can call Activity<MyType>.activities to see all running Live Activities, but assuming my end user has multiple instances running, how do I locate the instance that was started remotely?
Posted
by
Post not yet marked as solved
0 Replies
401 Views
I've been trying to implement an animation for my live activity. The animation is just rotating an image back and forth a bit and offsetting it up and down a bit. It'll give an airplane icon a subtle effect of "flying". Similar to the waveform animation in Apple Music, ie it's there for a it of visual flair. The documentation here states that withAnimation is ignored so I'm not entirely sure how these "constantly animating" effects are achieved. It seems like animations can only occur as transitions between states but it seems like overkill for my use-case of just wanting to animate a tiny bit of UI. Any advice would be greatly appreciated
Posted
by
Post not yet marked as solved
0 Replies
407 Views
Hello! Currently we are reviewing an issue whereby our users were obtaining Live Activities update, but somehow at the end, there were Live Activity updates that were not properly received by the device. For example: 20 Live Activity updates sent to device, 17 were properly received, however the last 3 were not properly received (as can be seen by the UI of it not updating). So far we have looked into a few root causes highlighted on the forums and on stackoverflow: Timestamp of APNS (every one of the APNS has a different timestamp) 200 is seen from the APNS side, which is why we were confused by the push notification did not arrive on the device side Looking into our logs, its unfortunately not covered enough to tell us when this had been received Some questions here: Is there a way we could log every Live Activity / Push Notification received from APNS? (for all scenario, app on lock screen, app in background) Anyway to track a push notification's lifecycle? I know the Push Notification Console tool is useful for debug usage, but we wanted to see if there's something similar for production usage as well.
Posted
by
Post not yet marked as solved
1 Replies
709 Views
My live activity is working perfectly on iOS 16.4 simulator but when I run the same code on iOS 17 or 17.2, the live activity does not show up anymore. There are no errors thrown and it says that the live activity is active.
Posted
by
Post not yet marked as solved
0 Replies
290 Views
We are using the below getPushToken() function to retrieve live activity token. However there are cases in production such that await activity.getPushToken() never finish. i.e. have logs of start event and no return or end event, the code path stuck at the guard statement. Do anyone face same issue and if can advise what can go wrong and how best to handle such cases? // log start event guard let pushToken = await activity.getPushToken(), !pushToken.isEmpty else { // log return event return } // log end event extension Activity { public func getPushToken() async -> String? { for await data in pushTokenUpdates { return data.map { String(format: "%02x", $0) }.joined() } return nil } }
Posted
by
Post not yet marked as solved
9 Replies
2.3k Views
Hi all, I'm trying to implement starting Live Activities with push notifications according to this article: https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications I'm using Xcode 15.1 beta 3, I have run my tests on a physical device with iOS 17.2 as well as the simulator with iOS 17.2 My problem is I can't seem to be able to get the pushToStartToken needed to start the live activities. I have subscribed to the pushToStartTokenUpdates but I never get any updates. Here is the code I used: Task { do { for try await data in Activity<DailyGoalActivityAttributes>.pushToStartTokenUpdates { let token = data.map {String(format: "%02x", $0)}.joined() print("Activity token: \(token)") } } catch { print(error) } } Any help would be greatly appreciated. Thanks, HS
Posted
by
Post not yet marked as solved
0 Replies
309 Views
Hi, I've been looking through the documentation for Live Activities and Activity Kit but I can't seem to get the answer to my question through the documentation. I have 2 questions: Is it possible to have a button on the live activity that shows & hides a certain element on the live activity? Is it possible to update the background color of the live activity? Thanks in advance, Sasri Product Designer
Posted
by
Post not yet marked as solved
0 Replies
485 Views
We are implementing new Live Activities in our app (we are a live shopping app). We also have PIP however i've noticed that when I start a live activity, then go into picture in picture, the dynamic island does not show the activity we've created for it. I can only see the activity on the lock screen widget while the audio for the videos plays. Is there any way to get the dynamic island to work with an app that is also in picture in picture? If there is and I'm doing something wrong, I can post some code. But from what I see, these don't seem to be compatible unfortunately :(
Posted
by
Post not yet marked as solved
0 Replies
354 Views
struct NetworkImage: View { let url: URL? var body: some View { Group { if let url = url, let imageData = try? Data(contentsOf: url), let uiImage = UIImage(data: imageData) { Image(uiImage: uiImage) .resizable() } else { Image("league") } } } } NetworkImage(url: URL(string: context.attributes.imageGame)) .aspectRatio(contentMode: .fill) .frame(width: 35, height: 35) .clipShape(Circle())
Posted
by
Post not yet marked as solved
1 Replies
542 Views
In this link, there is a description of live activity push token update: "The push token for a Live Activity may change throughout its duration. When your app receives a new token, it receives foreground runtime to process the updated token. Keep track of the push token for each Live Activity. Additionally, invalidate an outdated token on your server when you receive an updated token to successfully send subsequent updates." Our application did implement the solution to prepare for push token update. But so far, we don't see any occurrence of push token update from our backend records. The pushtokenupdates sequence only return the token once after live activity starts and does not emit more value afterward. Could you share a bit more on the condition for push token update? Under what circumstances will this happen? Thank you!
Posted
by
Post not yet marked as solved
1 Replies
429 Views
When I try to initiate a Live Activity using the iOS 16.2 API for it, which includes the staleDate, when the staleDate has passed, rather than transitioning my Live Activity to its special ended state, the Live Activity presumably crashes because it looks disabled with a loading spinner on top My ActivityAttributes struct is fairly simple, and the code that displays the "ended" state is itself not crashing, so unsure if I am doing something wrong Here is the code for my ActivityAttributes: struct TimerActivityAttributes: ActivityAttributes { enum TimerType: Codable { case rest, work } public struct ContentState: Codable & Hashable { var isEnded: Bool } let endDate: Date let exerciseName: String? let timerType: TimerType init(endDate: Date, exerciseName: String? = nil, timerType: TimerType = .rest) { self.endDate = endDate self.exerciseName = exerciseName self.timerType = timerType } } Here is the code that activates the Live Activity: private func startLiveActivityNew( attributes: TimerActivityAttributes, contentState: TimerActivityAttributes.ContentState ) { guard let endDate else { return } let activityContent = ActivityContent(state: contentState, staleDate: endDate) do { ActivityManager.shared.activity = try Activity.request( attributes: attributes, content: activityContent ) } catch (let error) { print("Caught an error: \(error.localizedDescription)") } } Here is the code I use to determine whether to display the ended state (to maintain compatibility with iOS 16.1): private func isEnded(context: ActivityViewContext<TimerActivityAttributes>) -> Bool { if #available(iOS 16.2, *) { if context.state.isEnded || context.isStale { return true } } else if context.state.isEnded { return true } return false } And this is what happens after staleDate has passed. I'm just not sure if I'm missing anything in my implementation
Posted
by
Post not yet marked as solved
0 Replies
360 Views
Hey there, I have noticed that my Live Activity's minimal presentation sometimes gets cut off when there is another app's Live Activity present. I tried adjusting the view in a number of ways, but it always seems to get cut off I'm just curious if this is a known issue with iOS 17, or if there is a potential workaround. This issue did not occur on iOS 16, and I've even updated to iOS 17.1 and the issue is still present. The view code is identical Here's the code that goes inside my minimal presentation ProgressView(timerInterval: Date.now...context.attributes.endDate, countsDown: true) { EmptyView() } currentValueLabel: { EmptyView() } .tint(.accent) And here is what ends up happening. I've also seen this with some of Apple's own Live Activities, so I'm assuming this is an iOS bug?
Posted
by
Post not yet marked as solved
0 Replies
271 Views
I am implementing the live activity in my project, it is a timer live activity so I have to dismiss it after the time ends for the particular activity. so for that, I'm doing it like this : Task { await activity.end(dismissalPolicy: .after(Date().addingTimeInterval(TimeInterval(1 * time)))) } it is working fine for live activity but when I'm calling this method while creating the live activity my dynamic island is not visible. am I doing something wrong here or missing out something.
Posted
by
Post not yet marked as solved
0 Replies
308 Views
In my App I use Live Activities that are updated using Push Notifications. This works fine and the Live Activities show the correct data. BUT: The data I get with these Push Notifications contain a geo location (latitude and longitude). And for these I want to display two things: 1.) The address that I want to decode using "CLGeocoder" with function "reverseGeocodeLocation", but this function is async and I can't get the app to start any async function. 2.) I would like to display a small Map with a Pin for this location. I want to use "MKMapSnapshotter" for this. But here the same async problem :( So, is there a way to handle this? Perhaps I just use the wrong point to start the async function. I tried ".task{}" and ."onAppear{}" But both are not working :(
Posted
by
Post not yet marked as solved
1 Replies
941 Views
Hi there, This is my first time posting here. I'm working on small projects on Swift and SwiftUI now and then. I'm currently trying to develop an application that gets some bus arrival data using API and displaying them with live activities. The thing is that I'm not quite sure how frequently updates work yet. Still trying to figure out if I can update the live activity everytime the data coming right from the API changes or use push notification updates each minute passing by, but that is another thread that I'm going to focus with more details. Everytime i'm trying to deploy my app on my iphone or a simulator this error keeps popping up and I can't figure out why. Any ideas? Let me know if you need any snippet of my code. SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.gregorikouk.MapKitTut.BusWidgetKit' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0xb1282dfe0 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.gregorikouk.MapKitTut.BusWidgetKit)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.gregorikouk.MapKitTut.BusWidgetKit)}}, FBSOpenApplicationRequestID=0xe5da, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.gregorikouk.MapKitTut.BusWidgetKit' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0xb1282dfe0 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.gregorikouk.MapKitTut.BusWidgetKit)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.gregorikouk.MapKitTut.BusWidgetKit)}}, FBSOpenApplicationRequestID=0xe5da, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}., NSUnderlyingError=0xb1281d830 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0xb1282dfe0 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.gregorikouk.MapKitTut.BusWidgetKit)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.gregorikouk.MapKitTut.BusWidgetKit)}}, FBSOpenApplicationRequestID=0xe5da, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}}} Domain: DTXMessage Code: 1 User Info: { DVTErrorCreationDateKey = "2023-10-02 21:06:04 +0000"; } -- System Information macOS Version 14.0 (Build 23A344) Xcode 15.0 (22265) (Build 15A240d) Timestamp: 2023-10-03T00:06:04+03:00
Posted
by