Widgets & Live Activities

RSS for tag

Discuss how to manage and implement Widgets & Live Activities.

WidgetKit Documentation

Posts under Widgets & Live Activities subtopic

Post

Replies

Boosts

Views

Activity

App Intent Parameter (AppEntity) not registering
I'm currently testing this on a physical device (12 Pro Max, iOS 26). Through shortcuts, I know for a fact that I am able to successfully trigger the perform code to do what's needed. In addition, if I just tell siri the phrase without my unit parameter, and it asks me which unit, I am able to, once again, successfully call my perform. The problem is any of my phrases that I include my unit, it either just opens my application, or says "I can't understand" Here is my sample code: My Entity: import Foundation import AppIntents struct Unit: Codable, Identifiable { let nickname: String let ipAddress: String let id: String } struct UnitEntity: AppEntity { static var typeDisplayRepresentation: TypeDisplayRepresentation { TypeDisplayRepresentation( name: LocalizedStringResource("Unit", table: "AppIntents") ) } static let defaultQuery = UnitEntityQuery() // Unique Identifer var id: Unit.ID // @Property allows this data to be available to Shortcuts, Siri, Etc. @Property var name: String // By not including @Property, this data is NOT used for queries. var ipAddress: String var displayRepresentation: DisplayRepresentation { DisplayRepresentation( title: "\(name)" ) } init(Unit: Unit) { self.id = Unit.id self.ipAddress = Unit.ipAddress self.name = Unit.nickname } } My Query: struct UnitEntityQuery: EntityQuery { func entities(for identifiers: [UnitEntity.ID]) async throws -> [UnitEntity] { print("[UnitEntityQuery] Query for IDs \(identifiers)") return UnitManager.shared.getUnitUnits() .map { UnitEntity(Unit: $0) } } func suggestedEntities() async throws -> [UnitEntity] { print("[UnitEntityQuery] Request for suggested entities.") return UnitManager.shared.getUnitUnits() .map { UnitEntity(Unit: $0) } } } UnitsManager: class UnitManager { static let shared = UnitManager() private init() {} var allUnits: [UnitEntity] { getUnitUnits().map { UnitEntity(Unit: $0) } } func getUnitUnits() -> [Unit] { guard let jsonString = UserDefaults.standard.string(forKey: "UnitUnits"), let data = jsonString.data(using: .utf8) else { return [] } do { return try JSONDecoder().decode([Unit].self, from: data) } catch { print("Error decoding units: \(error)") return [] } } func contactUnit(unit: UnitEntity) async -> Bool { // Do things here... } } My AppIntent: import AppIntents struct TurnOnUnit: AppIntent { static let title: LocalizedStringResource = "Turn on Unit" static let description = IntentDescription("Turn on an Unit") static var parameterSummary: some ParameterSummary { Summary("Turn on \(\.$UnitUnit)") } @Parameter(title: "Unit Unit", description: "The Unit Unit to turn on") var UnitUnit: UnitEntity func perform() async throws -> some IntentResult & ProvidesDialog { //... My code here } } And my ShortcutProvider: import Foundation import AppIntents struct UnitShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: TurnOnUnit(), phrases: [ "Start an Unit with \(.applicationName)", "Using \(.applicationName), turn on my \(\.$UnitUnit)", "Turn on my \(\.$UnitUnit) with \(.applicationName)", "Start my \(\.$UnitUnit) with \(.applicationName)", "Start \(\.$UnitUnit) with \(.applicationName)", "Start \(\.$UnitUnit) in \(.applicationName)", "Start \(\.$UnitUnit) using \(.applicationName)", "Trigger \(\.$UnitUnit) using \(.applicationName)", "Activate \(\.$UnitUnit) using \(.applicationName)", "Volcano \(\.$UnitUnit) using \(.applicationName)", ], shortTitle: "Turn on unit", systemImageName: "bolt.fill" ) } }
1
0
26
17h
AppIntentConfiguration WatchOS & iOS inconsistent
I'm having problems with my released app with iOS & WatchOS 26 support. I've added AppIntentConfiguration support in the WatchOS app such that users can configure the complication. My complications also support multiple families and so I have slightly different configuration options available if its in the .accessoryRectangular slot or the .accessoryCircular one. This works fine on Apple Watch when editing the Watch face. Here you can then select the configuration options fine and they are correct for the different variants. However on iOS when configuring in the Apple Watch app on iPhone, the different complication size is ignored and the same configuration options are offered meaning they are wrong for one of them. I created a sample project, here is the app intent code: struct TestWidgetConfigurationIntent: AppIntent, WidgetConfigurationIntent { static var title: LocalizedStringResource = "New Widgets with Configuration" static var description = IntentDescription("Lots of stuff.") static var isDiscoverable: Bool { return false} init() {} func perform() async throws -> some IntentResult { return .result() } @Parameter(title: "Enable More Detail", default: true) var moreDetail: Bool @Parameter(title: "Enable Other Parameter", default: true) var otherParameter: Bool static var parameterSummary: some ParameterSummary { When(widgetFamily: .equalTo, .accessoryRectangular) { Summary("Test Info") { \.$moreDetail \.$otherParameter } } otherwise : { Summary("Test Info") { \.$moreDetail } } } } In WatchOS you get the correct configuration options: In iOS you do not, you get the same configuration option regardless of which family size you select: This could be a bug so I've filed feedback FB20328319. Otherwise if anyone has insights, it would be very appreciated. This is all tested on the current iOS 26.0 and WatchOS 26.0 versions. Thanks!
1
1
88
20h
Unable to activate ActivityKit
Appears during code compilation Provisioning profile "iOS Team Provisioning Profile: ..*" doesn't include the com.apple.developer.ActivityKit entitlement, Has anyone encountered or resolved a similar issue where the ActiveKit feature was not found in the developer's identifier, despite not being activated in the developer's system?
1
0
34
1d
Adding a custom widget to the Capture group in Control Center
I noticed that with iOS 18, when adding a widget to the Control Center, there is now some "grouping system". I'm interested in the Capture group, which contains native widgets from Apple as well as third party apps like Instagram and Blackmagic cam, widgets in this group open the camera. My widget also opens the camera in my app, how can I add it to this group?
2
1
304
1d
Unable to activate ActiveKit
Appears during code compilation Provisioning profile "iOS Team Provisioning Profile: ..*" doesn't include the com.apple.developer.ActivityKit entitlement, Has anyone encountered or resolved a similar issue where the ActiveKit feature was not found in the developer's identifier, despite not being activated in the developer's system?
1
1
57
1w
Unable to activate ActivityKit
Appears during code compilation Provisioning profile "iOS Team Provisioning Profile: ..*" doesn't include the com.apple.developer.ActivityKit entitlement, Has anyone encountered or resolved a similar issue where the ActiveKit feature was not found in the developer's identifier, despite not being activated in the developer's system?
0
0
26
1w
App widget not appearing in widget list (intermittent)
There seems to be a long running issue with WidgetKit where some users don't see the widget when trying to add to their Home Screen. (even after opening the app for the first time). I have been able to reproduce myself intermittently, and typically restarting the phone or re-installing the app fixes the problem. However, some of my users have encountered this and end up requesting refunds because they think the app is broken. Has anybody else experienced this issue? Would be great to get this bug resolved as it's frustrating for users.
1
2
515
1w
privacySensitive on lockScreen does not seem to work...
Documentation seems to say that privacySensitive is supposed to redact on the lockScreen. I've disabled "Allow Access when locked" for "Lock Screen Widgets" just in case. It does not work for me. If I add "redacted(reason:) into the view hierarchy it redacts all the content all the time including on the home screen. I've read articles. I gone through a lot of documentation. None of them seem to give the magic formula for redacting sensitive content on the lock screen. I'm using iOS 18.7 on a real iPhone 14 Pro Max.
1
0
83
1w
The Flashlight Burnout
Often times myself and others have left flashlight on by accident. Burning it out for sometime of being in pocket or left on table the light stays on the whole time because of just not realizing it was on. The front of phone shows flashlight icon is white when light is on, but this is not good enough! The icon needs to be a bright red or some other color so user can see that the light is actually still on. This would help alot , ty
1
0
31
1w
WidgetKit: UIImage(named:) Fails to Load Asset After App Upgrade
Attachments: Problem Description: I encountered an issue related to WidgetKit. Inside a widget, I used the following API: UIImage(named: "some_pic_in_asset")! However, in my crash monitoring system, I observed a large number of crashes caused by force-unwrapping a UIImage that could not be loaded. After analyzing the crash reports and the associated app version information, I found that this issue consistently occurs during the app upgrade process. For example: A user installs the app at version A and adds the widget to their Home Screen. Later, the app is upgraded to version A+1. Then, in the monitoring backend, I observe many crashes. The crash itself happens under version A, but the report is uploaded under version A+1. Since crash collection happens in the widget and the report is uploaded by the app, the version mismatch is understandable. I also confirmed that the number of crashes strongly correlates with the number of app version upgrades. Based on this analysis, I believe that in the upgrade scenario described above, UIImage(named: "some_pic_in_asset") sometimes fails to load the image even though it exists in the asset catalog. Please note that the force-unwrapping operation is not the focus of my concern here. Question: Is this a known system issue? If so, is there a plan for fixing it in future iOS updates?
0
0
46
1w
Widget with Core Data guidance
I have an app that has a Core Data store for dates with descriptions that I'd like to present in a widget with countdown calculations. In the app I have a button that just equates an active calculation to the currently selected item in the database (using an EnvironmentObject). I gather I can't use this mechanism inside a widget, right? The user could put tons of items into the database - so I'm sure I don't want to have an editable widget allowing them to pick. I suppose I could create an intent and allow an independent entering from the app - but that seems rather user hostile since they've already entered it for the app - and I'm still trying to support iOS15 which doesn't support that. I did create an App Group and have the Core Data store available from within the widget, but I don't see how to allow the user to choose which date is active. I also want multiple widgets to be able to point to different dates. Any help would be appreciated. Thanks!
1
0
205
1w
Live activity custom format timer
We need a live activity to countdown our time in formats like 2h 30m -> 2h 29m -> 2h 28m etc 58m -> 57m I see this kind in pictures in official documentation. to make a functional timer is: Text(context.state.startTime, style: .timer) But it's very limited when it comes to formatting. This timer .relative includes seconds which we don't want Text(futureDate, style: .relative) Also format we need is h instead of hour, m instead of min
0
1
22
2w
Live Activity updates not received on iPhone 16 Pro Max when started via ActivityKit push
Description When starting Live Activities via ActivityKit push notifications, the “start” notification is received correctly on iPhone 16 Pro Max, but subsequent update or end push notifications are not. The same implementation on iPhone 16 Pro behaves as expected (both start and update/end notifications are delivered and processed). Environment Property Value Device (failing) iPhone 16 Pro Max Device (working) iPhone 16 Pro iOS Version 18.5 Xcode / SDK 16.2/ActivityKit / Push Notifications Network Wi-Fi / Cellular (both tested) Data Collection Method Devices connected via USB. Logs captured using Console.app. Log filtering applied for the liveactivitiesd daemon to isolate Live Activity behavior. Initial Triage/Observations Payload format confirmed compatible; no incompatible fields. APNs token remains the same across messages (no refresh). Identical ActivityKit subscriptions/participants on both devices. Server-side delivery is confirmed: iPhone 16 Pro receives all messages (start, update, end). Only iPhone 16 Pro Max fails to receive update or end push notifications. Log Analysis iPhone 16 Pro (Working) Push-to-Start successfully received: 13:45:20 - APSXPCDeliverMessageEvent: Created APSIncomingMessage 13:45:20 - Received message: eventType: start(SessionPushNotifications.IncomingMessage.EventType.StartParameters(attributesType: "AchToLSUpgradeAttributes", attributesData: 125 bytes, inputs: [])) 13:45:20 - Created activity: 1C081AC5-01AE-4EC0-8B67-5F2A9FAE2D60 13:45:45 - APSXPCDeliverMessageEvent: Created APSIncomingMessage 13:45:45 - Received message: eventType: end(dismissDate: Optional(2025-07-21 21:00:44 +0000)) 13:45:20 - Activity updated: 1C081AC5-01AE-4EC0-8B67-5F2A9FAE2D60 13:45:20 - Local activity did update: 1C081AC5-01AE-4EC0-8B67-5F2A9FAE2D60 iPhone 16 Pro Max (Failing) 13:56:39 - APSXPCDeliverMessageEvent: Created APSIncomingMessage 13:56:39 - Received message: eventType: start(SessionPushNotifications.IncomingMessage.EventType.StartParameters(attributesType: "AchToLSUpgradeAttributes", attributesData: 125 bytes, inputs: [])) 13:56:39 - Created activity: E6BBF691-0C7A-4791-98D2-6F1440D9932E **No subsequent APNs push-to-update or push-to-end messages received.** 13:56:39 - No destinations for event E6BBF691... of type start 13:56:40 - No destinations for event E6BBF691... of type update Questions for Apple Engineering Are there known issues with ActivityKit push notifications specifically on iPhone 16 Pro Max devices? What additional diagnostic logs (system, APNs, liveactivitiesd) would be most helpful to collect? Could device-specific power management, notification settings, or OS-level changes on Pro Max models affect Live Activity updates? Are there differences in how Live Activity push subscriptions or routing are handled on iPhone 16 Pro Max vs Pro that could lead to this issue?
0
0
53
2w
Get update token from the OS when the Live Activity is started from the backend, without the user explicitly providing "Allow" or "Always Allow" consent from the lock screen
We are currently using Live Activities in our app and supporting both of the following use cases: Starting a Live Activity directly from the app using ActivityKit APIs. Starting a Live Activity from the backend using the start token. In the first case (initiated from the app), the OS generates an update token, and we are able to continuously update the Live Activity via our backend—even if the user has not explicitly provided "Allow" or "Always Allow" consent from the lock screen. This works as expected. In the second case (initiated from the backend), if the user does provide consent ("Allow" or "Always Allow") from the lock screen, we receive the update token and can continue updating the Live Activity. However, if the user does not provide consent, the OS does not provide the update token, and we are unable to send further updates. Question: Is it possible to receive the update token from the OS when the Live Activity is started from the backend, without the user explicitly providing "Allow" or "Always Allow" consent from the lock screen? We would appreciate any clarification or official documentation related to this behavior. Thank you!
0
4
99
2w
how to suppress sound of a live activity when app is foregrounded?
Regular apns will give you a willPresent callback and there you can decide to suppress showing the notification or suppress its sound etc. I know the iOS app will give you callbacks for when there's a contentUpdate, yet that doesn't give the option to change the sound. Is there a way to suppress sound of a received Live Activity when app is in foreground?
0
1
47
2w
Push tokens from push-to-start Live Activities require user permissions?
Just wanted to clarify some expected behaviors here. It seems that there are two distinct behaviors for Live Activity flows for freshly installed apps. When you start a Live Activity for the first time and the user hasn't yet clicked on Allow/Don't Allow in the activity interface, there are two different sequences: Starting a Live Activity locally Request a Live Activity locally via Swift Live Activity starts .pushTokenUpdates is immediately triggered, even if the Allow/Don't Allow buttons appear under the Activity UI Starting a Live Activity via push-to-start Send a push-to-start notification to launch a Live Activity Live Activity starts .pushTokenUpdates is not triggered, and .pushToken returns nil. If a user clicks on Allow in the Activity UI, only then is .pushTokenUpdates triggered.
0
3
94
2w
Migrate Widgets from StaticConfiguration to IntentConfiguration
New features in WatchOS 26 with configurable widgets make it more important than ever that apps adopt IntentConfiguration options where applicable. I develop an app with an Apple Watch complication/widget on many many user's Watch faces around the world. I've completed updating my code to support WidgetKit and remove ClockKit. However, I face huge issues adding support for users to configure their widget/complications. If I update a widget to go from StaticConfiguration to IntentConfiguration, even when keeping the "kind" string the same, the widget disappears from the Watch face. This is an unacceptable user experience meaning I can't proceed with the migration. The problem is users will expect me to offer configuration in the Watch face soon for their widget/complication. Currently this process is done in a sub-optimal way in the app itself. A similar issue exists on iOS where the widget will just "freeze" indefinitely is migrated. This issue still occurs on the iOS 26 and WatchOS 26 betas. So how to move this forward. This has been discussed previously here: https://developer.apple.com/forums/thread/661247 I've mentioned it at WidgetKit labs I've filed feedback last year: FB13880020 I've filed feedback this year: FB18180368 It seems really important this gets fixed for developers to adopt these new features, is there any other migration route I'm missing or a workaround that would mitigate this seemingly big problem.
4
1
145
2w
Live Activity life cycle
A Live Activity relies on its app being in the background , but contrary to a widget it does not have a timeline. Our app "in the making" is sandboxed and does not need to receive ActivityKit push notifications How is the app "maintained in life" and not entirely killed for the duration of the activity - Apple documentation says up to 8 hours ? Is it necessary for us to do something to maintain it, like to trick the system , play a white noise audio background ...?
0
0
38
3w