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

We would like to inquire about the push notification budget for Live Activities.
We are developing a service that uses the “More Frequent Updates” feature of Live Activities. I have a question regarding the push notification budget for Live Activities. According to the documentation and the following session: WWDC23 Session 10185 – “What’s New in ActivityKit” https://developer.apple.com/videos/play/wwdc2023/10185/ At 11:58, it is stated that there is no limit on the number of updates when using low priority (5). Could you confirm whether updates sent with low priority (5) are indeed not subject to the Live Activity push notification budget?
0
0
71
May ’25
Data Race in Widgets?
I've turned on Swift 6 language mode and noticed that during runtime Xcode gives this warning for a new widget (iOS 17.2): warning: data race detected: @MainActor function at TestWidgetExtension/TestWidget.swift:240 was not called on the main thread struct TestWidget: Widget { let kind: String = "TestWidget" var body: some WidgetConfiguration { AppIntentConfiguration( kind: kind, intent: ConfigurationAppIntent.self, provider: Provider() ) { entry in // LINE 240 TestWidgetEntryView(entry: entry) .containerBackground(Color.white, for: .widget) } } } Is there any way to solve this on my side? Thank you!
1
0
53
Jun ’25
AppIntent perform function is not invoked from ControlWidget
I have an AppIntent that edits an object in my app. The intent accepts an app entity as a parameter, so if you run the intent it will ask which one do you want to edit, then you select one from the list and it shows a dialog that it was edited successfully. I use this same intent in my Home Screen widget initializing it with an objectEntity. The code needs to run in the app's process, not the widget extension process, so the file is added to both targets and it conforms to ForegroundContinuableIntent, and that is supposed to ensure it always runs in the app process. This works great when run from the Shortcuts app and when involved via a button in the Home Screen widget, exactly as expected. Here is that app intent: @available(iOS 17.0, *) struct EditObjectIntent: AppIntent { static let title: LocalizedStringResource = "Edit Object" @Parameter(title: "Object", requestValueDialog: "Which object do you want to edit?", inputConnectionBehavior: .connectToPreviousIntentResult) var objectEntity: ObjectEntity init() { print("INIT") } init(objectEntity: ObjectEntity) { self.objectEntity = objectEntity } @MainActor func perform() async throws -> some IntentResult & ReturnsValue<ObjectEntity> & ProvidesDialog { // Edit the object from objectEntity.id... return .result(value: objectEntity, dialog: "Done") } } @available(iOS 17.0, *) @available(iOSApplicationExtension, unavailable) extension EditObjectIntent: ForegroundContinuableIntent { } I now want to create a ControlButton that uses this intent: struct EditObjectControlWidget: ControlWidget { var body: some ControlWidgetConfiguration { StaticControlConfiguration(kind: "EditObjectControlWidget") { ControlWidgetButton(action: EditObjectIntent()) { Label("Edit Object", systemImage: "pencil") } } } } When I add the button to Control Center and tap it (on iOS 18), init is called 3x in the app process and 2x in the widget process, yet the perform function is not invoked in either process. No error appears in console logs for the app's process, but this appears for the widget process: LaunchServices: store <private> or url <private> was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} Attempt to map database failed: permission was denied. This attempt will not be retried. Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} What am I doing wrong here? Thanks!
1
0
108
Jul ’25
WatchOS26 ControlWidget
WatchOS26 ControlWidget cannot display image copy or click import Foundation import SwiftUI import WidgetKit import AppIntents internal import Combine struct WidgetToggle: ControlWidget { var body: some ControlWidgetConfiguration { StaticControlConfiguration(kind: "com.example.myApp.performActionButton", provider: TimerValueProvider()) { isRunning in ControlWidgetToggle("WidgetToggle", isOn: isRunning, action: ToggleTimerIntent()) { isOn in Label(isOn ? "Running" : "Stopped", systemImage: isOn ? "hourglass.bottomhalf.filled" : "hourglass") } } .displayName("WidgetToggle") .description("WidgetToggle description") } } struct TimerValueProvider: ControlValueProvider { var previewValue: Bool { return false } func currentValue() async throws -> Bool { return TimerManager.shared.isRunning } } struct ToggleTimerIntent: SetValueIntent { static var title: LocalizedStringResource = "WidgetToggle" @Parameter(title: "Toggle") var value: Bool func perform() async throws -> some IntentResult { TimerManager.shared.isRunning = value return .result() } } class TimerManager: ObservableObject { static let shared = TimerManager() @Published var isRunning = false }
0
0
89
Jun ’25
Live Activity not displaying in Dynamic Island
I am developing Live Activities using Swift. The same code can display the lock screen view and Dynamic Island on most devices, but on one specific iPhone 16 Pro Max, the Dynamic Island is not shown. The system version is iOS 18.0. However, other apps on this phone can display the Dynamic Island normally. How should I troubleshoot the issue? Can anyone help me? Thank you.
0
0
47
Jun ’25
生产版本clip轻应用无法展示
我们在使用clip轻应用功能,在App Store Connect中配置了高级轻应用体验,并配置了相关的https链接(在构建版本页面此域名是已验证状态),但是我们在使用此链接进行NFC触碰时,不会拉起来clip轻应用,只会显示“XXXX NFC标签”,使用Apple的官方链接:https://appclip.apple.com/id?p=xxxx,是可以拉起来轻应用的,请问各位大佬,我们的问题出现在哪?该如何解决?
0
0
69
Jun ’25
Surfacing time-sensitive shortcuts with AppIntents framework
I'm currently working on enhancing our app’s support for App Intents. We're aiming to suggest time-sensitive shortcuts to Spotlight and Siri — for example, proactively surfacing certain shortcut from 2 hours before some event the user has registered in their database until 2 hour after that. I’ve been reviewing the AppIntents framework documentation but haven’t found a definitive answer on whether this is currently achievable. From what we understand, the RelevantIntent and RelevantContext APIs appear to support time-based suggestions, but they seem to apply only to Widgets, not to standalone app shortcuts. Is this understanding correct, and is there a recommended approach for achieving time-sensitive shortcut suggestions outside of a Widget context? Any guidance would be greatly appreciated. Best regards,
0
0
55
Jun ’25
How to start live activity in terminated state?
Hi everyone and Apple support, I’ve built an app that continuously runs and receives temperature data from a sensor. When a threshold is reached, I use Live Activities with the push notification flow to display alerts on the Dynamic Island. The Live Activity and push notification flow work fine in foreground and background states. However, I’m trying to support push-triggered Live Activities when the app is in the terminated state. Since my app rarely terminates, I can’t confirm if the Live Activity push token is generated in that state. It seems like it isn’t, which blocks the Live Activity from starting via push. I tried with both pushtostarttoken and pushtostarttokenupdates. None of them worked. Has anyone dealt with this or found a workaround to ensure the push token is available even when the app is terminated?
0
0
116
Jul ’25
Feature Flagging Widgets & Widget Families
I am trying to feature flag widgets in my Widget extension. This feature flag value is stored remotely, read by my main app, and written to UserDefaults, then read from UserDefaults in my widget target. I understand that providing an empty array of WidgetFamilys will not show my app when the user goes to add a widget. However, even when this flag flips to true, hard-closing and reopening my app will not show my app in the list of apps you can add a widget for. But I notice that if I recompile my app from Xcode (running the app's scheme, not the widget scheme), then my app will show when you search for an app to add a widget for, making me think that these Widget objects are only created by the system once when the app is initially installed/updated. My concern is that I will not be able to flip this flag from false to true after the user has installed my app to do a rollout of my widget. Is this expected? Or is there an alternative or otherwise recommended way of doing this? struct MyWidget: Widget { let kind = "MyWidget" var supportedFamilies: [WidgetFamily] { let manager = ExtensionManager() if manager.widgetsEnabled { return [.systemSmall, .systemMedium, .systemLarge] } else { return [] } } var body: some WidgetConfiguration { IntentConfiguration( kind: kind, intent: MyWidgetIntent.self, provider: MyWidgetProvider() ) { entry in MyWidgetView(entry: entry) } .configurationDisplayName("My Widget") .description("Install my widget!") .supportedFamilies(supportedFamilies) } }
0
0
112
Jul ’25