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 Shortcuts Limitations
I've been implemented App Shortcuts into my apps which are localized for a variety of languages. The WWDC23 "Spotlight your app with App Shortcuts" has been extremely helpful in resolving my localized trigger phrases issue, but before I continue filling out all of the trigger phrases for my application I am concerned about a limitation that was mention in the video and need some additional information about it. The limitations noted in the video at minute mark 21:26 states that: Maximum 10 App Shortcuts (OK) Maximum 1000 trigger phrases... If I have 1 app and 10 shortcuts, and each shortcut only uses (.applicationName), this means I get to have 100 trigger phrases for each shortcut (for the sake of the discussion). What I'm unsure about is when I begin providing localization do the localized triggered phrases count toward the trigger phrase limit? Essentially, for every language I support do I have to drop 1/2 of all of my trigger phrases to stay under the limit? At the moment, my app is supporting 40 languages and I would like to know how localization affects the trigger phrase limit. Thank you!
1
0
104
21h
Detect if a widget is displayed in CarPlay vs. iPhone/iPad
I am looking into the new CarPlay support for systemSmall widgets introduced in iOS 26 (Apple documentation). I am trying to figure out if there is a way to programmatically detect whether the widget is currently being displayed on the iPhone/iPad home/lock screen or in CarPlay. So far, I haven’t found any information in the documentation or APIs that indicate how to distinguish between these environments. Is there an API, environment value, or best practice for handling this scenario? Thanks in advance for any insights!
1
1
123
1d
Live Activities Push-to-Start flows
Good morning, We are implementing Live Activities in a push-to-start flow. We wrap the listener for push to start tokens in a high priority task: if ptsListenerTask == nil || ptsListenerTask?.isCancelled == true { ptsListenerTask = Task(priority: .high) { [weak self] in for await pushToken in Activity<LiveAuctionAttributes>.pushToStartTokenUpdates { //Send token to back-end } } I've tried a few variations of this and they work well on most devices. I have seen a couple of devices that refuse to issue a push to start token. The user will have logging for the init flow and starting the PTS listener then the logs just go silent, nothing happens. One thing that seemed to work was getting the user to start a Live Activity manually (from our debugging tool) then the PTS token gets issued. This is not very reliable and working a mock live activity into the flow for obtaining a PTS token is a poor solution. Is anyone else seeing this and is there a known issue with obtaining PTS tokens? Thanks! Brad
8
1
204
1w
iOS 26 - Widget not updated with respect to main app's system preferred language
Hi, My iOS app's home screen widget content was implemented to base on the preferred language of my main app (e.g. my app has the following preferred language options with this order English, Japanese, Traditional Chinese, Korean, Simplify Chinese). Say the main app is currently using English as their preferred language, I can change the preferred language in the iOS Settings -> Apps -> My App -> Preferred Language. My widget's content will respect to the preferred language option that I selected with only exception if I switch back to English language and my Widget's content won't get updated. The Main app content is always update with respect to the selected preferred language. My app and widget is working without any issue in iOS 18. Other things that I had discovered during my testing under iOS 26, the "first" language appeared in my preferred language always being the issue (e.g. if the first language is Japanese , once I change to other languages and than switch back to Japanese, my widget content won't respect to this but the main app content are ok). Any one has a similar issues regarding the preferred language?
3
2
236
1w
Contrast for texts in widgets with image backgrounds transparent mode
Hello, in my widget the user displays images filling the whole widget with overlayed texts (via ZStack). Via shadows or text background color the text gets better readable. However, when a user chooses transparent or tinted colors for the home screen, the text is barely or not readable anymore since e.g. white text on white image background. How to resolve this issue?
5
0
89
1w
How to Update a Live Activity from a Widget Extension When Local Notifications Are Active?
I’m manipulating some data inside a widget extension, and at the same time there is an active Live Activity (Dynamic Island / Lock Screen). How can I update the Live Activity’s local notification when the data changes? I tried accessing the current activity using Activity.activities, but it seems that this API is not accessible from inside the widget extension. What is the correct way to refresh or update the Live Activity in this case?
0
0
30
1w
How can you update a Live Activity without hitting "Allow"?
(I truly appreciate all the responses you all have written for me :bow: ) I was under the assumption that for Live Activity, in order for you to be able to update the Activity, you need an update token. And for the OS to issue you the update token, user must hit the "Allow" from the lock screen. However based on these screenshots it seems that you don't need to hit "Allow" to be able to update the Live Activity. Live Activity was updated — even without the user hitting "Allow" So now I'm wondering if: Is hitting Allow required for the update token to get issued? Or that assumption is incorrect? In our tests (when connected to Proxyman, the OS emits the update token after user hits "Allow" / "Always Allow") If you don't hit allow, are there alternate ways to update the Live Activity without having the update token? I'm guessing you could set a short stale time and then when the OS launches the app in the background you query the server and then update the Live Activity. Is that a worthy approach? I also noticed that the "The Philly Inquirer" App has 'Background App Refresh" enabled, but this happened in 2 minutes. In our architecture assessments, after reviewing Apple's docs on 'Background Processing", we didn't think of it as a viable option, because it can't guarantee if the OS is given time in the next 2 minutes or 10 hours later when the phone is getting charged again. Are any of these workarounds viable or are there alternate approaches? Our requirement is: be able to use Live Activity between 2-72hrs after app install. (I mention this because perhaps Apple may impost some restrictions for new installs) be able to update an active Live Activity within 1-2 minutes after it has began.
0
0
50
1w
App intent with parameter launches app before taking user input
I built a couple of app intents for macOS, which generally work great. However, I'm struggling with configuring an app intent that takes a parameter, so that it doesn't require the app to launch before presenting people with the list of options. If the app is running and I run the intent in Spotlight, I can see the message defined by the intent's parameterSummary and I can select a parameter from the list of entities. If the app is not running, it is launched first and only then the intent message fully populates in Spotlight and allows parameter selection. What I've tried: Support background or deferred mode in the intent. Conformed the entities to IndexedEntity. Conformed the entity query to EnumerableEntityQuery, implementing suggestedEntities and allEntities. Conformed the entity query to EntityStringQuery. Donated the intent to Spotlight on app launch. Donated the entities to Spotlight on app launch, both using indexSearchableItems and indexAppEntities. Not sure if both are required or if the latter is just a more convenient version of the former. Do I have to conform to or implement something else? Do I need to work with an app intent extension? If so, would I put all app intent code into the extension instead of the main app? Is this a system bug I should file?
0
0
32
2w
Snippet Views don't render consistently, width not always respected
I've created a Snippet for my iOS app which I want to be able to run from the LockScreen via a Shortcuts widget. All works fine except when I run the shortcut and the App Snippet appears, it doesn't always render the SwiftUI view in the same way. Sometimes the width boundaries are respected and sometimes not. I've tested this on iOS 26.1 and iOS 26.2 beta 3 I think this is a bug but it would be great if anyone could see what I might be doing wrong if it's not. Incase it is a bug I've filed a feedback (FB21076429) and I've created a stripped down sample project showing the issue and added screenshots showing the issue. Basic code to reproduce issue: // Intent.swift // SnippetBug import AppIntents import Foundation import SwiftUI struct SnippetEntryIntent: AppIntent { static let title: LocalizedStringResource = "Open Snippet" static let description = IntentDescription("Shows a snippet.") // Don’t open the app – stay in the snippet surface. static let openAppWhenRun: Bool = false func perform() async throws -> some ShowsSnippetIntent { .result(snippetIntent: TestSnippetIntent()) } } struct TestSnippetIntent: SnippetIntent { static let title: LocalizedStringResource = "Snippet Intent" static let description = IntentDescription("Action from snippet.") @MainActor func perform() async throws -> some IntentResult & ShowsSnippetView { .result(view: SnippetView(model: SnippetModel.shared)) } } @MainActor final class SnippetModel { static let shared = SnippetModel() private init() { } } struct SnippetView: View { let model: SnippetModel var body: some View { HStack { Text("Test Snippet with information") Spacer() Image(systemName: "heart") }.font(.headline) } } struct Shortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: SnippetEntryIntent(), phrases: [ "Snippet for \(.applicationName)", "Test Snippet \(.applicationName)" ], shortTitle: "Snippet", systemImageName: "barcode" ) } } You also need these lines in your main App entry point: import AppIntents @main struct SnippetBugApp: App { init() { let model = SnippetModel.shared AppDependencyManager.shared.add(dependency: model) } var body: some Scene { WindowGroup { ContentView() } } } This is correct This is incorrect
0
0
42
2w
The application crashed on the ios12 system
The iap package typed with macos26 xcode26 crashed on ios12 add WidgetKit and set its Status to "Optional" #if canImport(WidgetKit) import WidgetKit #endif We have already modified the configuration in these two ways. There are no issues on ios13 and above systems, but it won't start on ios12. However, we want to support the lowest version of ios12. How can we solve this problem,The crash might still be the one below dyld: Library not loaded: /System/Library/Frameworks/WidgetKit.framework/WidgetKit Referenced from: /private/var/containers/Bundle/Application/CA01C3C8-5010-4EDC-8089-058A3A4E79E7/bodianplayer.app/bodianplayer Reason: image not found
0
0
108
2w
Mac OS 26.1 Crash widget when create UIWindow
Hello, Users are reporting that widgets in my iOS app running on Mac OS are starting to crash after updating to MacOS 26.1. Everything works fine on iOS 26.1 and MacOS 15.6. The same bugs I found in iOS 26 beta 4, but then Apple fixed them in iOS 26RC and now they're back in macOS. Any suggestions? Crash report: Process: WidgetWebWidgetExt [23580] Path: /Volumes/VOLUME/*/WidgetWeb.app/PlugIns/WidgetWebWidgetExt.appex/WidgetWebWidgetExt Identifier: app.vitalek.widgetapp.web.WidgetWebExt Version: 7.5 (5796) AppVariant: 1:MacFamily20,1:18 Code Type: ARM-64 (Native) Role: unknown Parent Process: launchd [1] Coalition: app.vitalek.widgetapp.web.WidgetWebExt [28539] User ID: 501 Date/Time: 2025-11-04 11:47:19.0746 -0500 Launch Time: 2025-11-04 11:47:18.8035 -0500 Hardware Model: Mac14,6 OS Version: macOS 26.1 (25B78) Release Type: User Crash Reporter Key: 39D39455-7F69-746C-2A1D-7A6086F25541 Incident Identifier: 7AC31574-73A4-4320-B17A-C2819252EEDA Sleep/Wake UUID: 1535756C-44D8-497F-A288-07E53CD9B9E4 Time Awake Since Boot: 18000 seconds Time Since Wake: 7417 seconds System Integrity Protection: enabled Triggered by Thread: 0, Dispatch Queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 6, Abort trap: 6 Terminating Process: WidgetWebWidgetExt [23580] Application Specific Information: abort() called Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x1926e75b0 __pthread_kill + 8 1 libsystem_pthread.dylib 0x192721888 pthread_kill + 296 2 libsystem_c.dylib 0x192626850 abort + 124 3 libc++abi.dylib 0x1926d5858 __abort_message + 132 4 libc++abi.dylib 0x1926c44d4 demangling_terminate_handler() + 304 5 libobjc.A.dylib 0x1922f0414 _objc_terminate() + 156 6 libc++abi.dylib 0x1926d4c2c std::__terminate(void (*)()) + 16 7 libc++abi.dylib 0x1926d8394 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 88 8 libc++abi.dylib 0x1926d833c __cxa_throw + 92 9 libobjc.A.dylib 0x1922e6580 objc_exception_throw + 448 10 Foundation 0x19495122c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 288 11 UIKitMacHelper 0x1b0240c80 -[UINSApplicationDelegate init] + 1348 12 UIKitMacHelper 0x1b02406d8 __41+[UINSApplicationDelegate sharedDelegate]_block_invoke + 48 13 libdispatch.dylib 0x19257eac4 _dispatch_client_callout + 16 14 libdispatch.dylib 0x192567a60 _dispatch_once_callout + 32 15 UIKitMacHelper 0x1b02405dc +[UINSApplicationDelegate sharedDelegate] + 324 16 UIKitCore 0x1ca488518 -[UIScene setTitle:] + 188 17 UIKitCore 0x1ca487e90 -[UIScene initWithSession:connectionOptions:] + 1084 18 UIKitCore 0x1cb2a6a54 -[UIWindowScene initWithSession:connectionOptions:] + 92 19 UIKitCore 0x1ca66b44c -[_UIScreenBasedWindowScene initWithScreen:session:lookupKey:] + 292 20 UIKitCore 0x1ca66aff4 +[_UIScreenBasedWindowScene _unassociatedWindowSceneForScreen:create:] + 408 21 UIKitCore 0x1cb09171c -[UIWindow _uiWindowSceneFromFBSScene:] + 704 22 UIKitCore 0x1cb0918cc -[UIWindow _initWithFrame:debugName:scene:attached:] + 92 23 UIKitCore 0x1cb091e68 -[UIWindow _initWithOrientation:] + 56 24 UIKitCore 0x1cb091ebc -[UIWindow init] + 72 25 WidgetWebWidgetExt 0x1027eb250 0x102718000 + 864848 26 WidgetWebWidgetExt 0x1027ea418 0x102718000 + 861208 27 WidgetWebWidgetExt 0x1027f5bc8 0x102718000 + 908232 28 WidgetWebWidgetExt 0x1027f4bfc 0x102718000 + 904188 29 WidgetWebWidgetExt 0x1027cf9f4 0x102718000 + 752116 30 WidgetWebWidgetExt 0x102807c20 0x102718000 + 982048 31 libdispatch.dylib 0x19257eac4 _dispatch_client_callout + 16 32 libdispatch.dylib 0x1925696e4 _dispatch_continuation_pop + 596 33 libdispatch.dylib 0x19257c800 _dispatch_source_latch_and_call + 396 34 libdispatch.dylib 0x19257b4d4 _dispatch_source_invoke + 844 35 libdispatch.dylib 0x19259c008 _dispatch_main_queue_drain.cold.5 + 592 36 libdispatch.dylib 0x192573f48 _dispatch_main_queue_drain + 180 37 libdispatch.dylib 0x192573e84 _dispatch_main_queue_callback_4CF + 44 38 CoreFoundation 0x1927ea980 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 39 CoreFoundation 0x1927bf7dc __CFRunLoopRun + 1944 40 CoreFoundation 0x19287935c _CFRunLoopRunSpecificWithOptions + 532 41 Foundation 0x194a06890 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 42 Foundation 0x194005a50 -[NSRunLoop(NSRunLoop) run] + 64 43 libxpc.dylib 0x19240ce14 _xpc_objc_main + 668 44 libxpc.dylib 0x19241ecf8 _xpc_main + 40 45 libxpc.dylib 0x19241ecd0 xpc_bs_main + 16 46 BoardServices 0x1ac51179c +[BSServicesConfiguration activateXPCService] + 72 47 ExtensionFoundation 0x237a92710 _EXRunningExtension.resume() + 1592 48 ExtensionFoundation 0x237a911a8 _EXRunningExtension.start(withArguments:count:) + 124 49 ExtensionFoundation 0x237a88f24 EXExtensionMain(_:_:) + 668 50 Foundation 0x1940065ec NSExtensionMain + 200 51 dyld 0x192359d54 start + 7184
1
0
43
2w
watchOS: AppIntents.IntentRecommendation description ignored when applying a .watchface
When we use AppIntents to configure WidgetKit complications, the description we provide in IntentRecommendation is ignored after applying a .watchface file that includes those intent configurations. In the Watch app, under Complications, the labels shown next to each slot do not match the actual complications on the face—they appear to be the first strings returned by recommendations() rather than the selected intent configuration. Steps to Reproduce Create an AppIntent used by a WidgetKit complication (e.g., .accessoryRectangular). Provide multiple intent recommendations with distinct descriptions: struct SampleIntent: AppIntent { static var title: LocalizedStringResource = "Sample" static var description = IntentDescription("Sample data") @Parameter(title: "Mode") var mode: String static func recommendations() -> [IntentRecommendation<Self>] { [ .init(intent: .init(mode: "A"), description: "Complication A"), .init(intent: .init(mode: "B"), description: "Complication B"), .init(intent: .init(mode: "C"), description: "Complication C") ] } func perform() async throws -> some IntentResult { .result() } } Add two of these complications to a Modular Duo face (or any face that supports multiple slots), each with different intent configurations (e.g., A in one slot, B in another). Export/share the face to a .watchface file and apply it on another device. Open the Watch app → the chosen face → Complications. Expected Each slot’s label in Complications reflects the specific intent configuration on the face (e.g., “Complication A”, “Complication B”), matching what the complication actually renders. Actual The labels under Complications do not match the visible complications. Instead, the strings shown look like the first N items from recommendations(), regardless of which configurations are used in each slot. Notes The complications themselves render correctly on-watch; the issue is the names/labels displayed in the Watch app UI after applying a .watchface. Filed Feedback: FB20915258
3
3
112
2w
Live Activity – crashes on ActivityAuthorizationInfo() and Activity.activities
Hey! I'm working on enabling remotely started live activities. I'm running into 2 crashes: Upon initializing ActivityAuthorizationInfo Upon calling Activity<...>.activities array Both stack traces look like this: 0 libsystem_kernel.dylib +0xce0 _mach_msg2_trap 1 libsystem_kernel.dylib +0x4398 _mach_msg2_internal 2 libsystem_kernel.dylib +0x42b4 _mach_msg_overwrite 3 libsystem_kernel.dylib +0x40fc _mach_msg 4 libdispatch.dylib +0x1cc04 __dispatch_mach_send_and_wait_for_reply 5 libdispatch.dylib +0x1cfa4 _dispatch_mach_send_with_result_and_wait_for_reply 6 libxpc.dylib +0x107ec _xpc_connection_send_message_with_reply_sync 7 BoardServices +0xaea8 -[BSXPCServiceConnectionMessage _sendWithMode:] 8 BoardServices +0x17938 -[BSXPCServiceConnectionMessage sendSynchronouslyWithError:] 9 BoardServices +0xeef0 ___71+[BSXPCServiceConnectionProxy createImplementationOfProtocol:forClass:]_block_invoke They happen to a limited number of users, but not insignificant. Most are on iOS 18.6.2 and iOS 26.1, but there are others in the mix. I don't have a repro myself. It looks like the main thread gets blocked after we receive no response from these ActivityKit APIs. Both of these are called inside application:didFinishLaunchingWithOptions:. For ActivityAuthorizationInfo, we need the app to communicate with the server whether the user has live activities enabled; hence, calling this object's init as early as possible in the app. For activities array, I'd like to do some logging whenever the live activity is started or ended (for example, if activities array no longer contains any activities, we can log the activity as dismissed). For this logging to happen, as far as I understand, it has to happen inside didFinishLaunchingWithOptions since this is the only method being called upon the terminated app receiving background runtime when the live activity starts/ends remotely. After some research, one potential reason is ActivityKit APIs are just not ready to return values via xpc connection at app startup, so moving these methods to applicationDidBecomeActive could resolve the problem. That's fine for ActivityAuthorizationInfo init, but for accessing activities, there is no other place in the lifecycle to see if an activity has been dismissed (especially in the scenario where app is terminated, so we get only 30 seconds ish of background runtime). Curious if anyone has run into this or has any insights into ActivityKit API behavior.
0
0
47
3w
What should your server do when apns returns a 410 Unregistered error for your token?
For our Live Activity Tokens, when we fire a payload, often apns is returning a response of 410 unregistered. Docs are saying: The device token is inactive for the specified topic. There is no need to send further pushes to the same device token, unless your application retrieves the same device token, refer to Registering your app with APNs Questions: Why does this happen? Does it only happen because the user changed their permission? Or there are other reasons? And when it does happen, what should we do about it? A. Should we keep the token on the server? Because perhaps the user will change their permission and the token becomes valid? That could leave us with lots of invalid tokens and us firing at them unnecessarily. Docs do say: Don’t retry notification responses with the error code BadDeviceToken, DeviceTokenNotForTopic, Forbidden, ExpiredToken, Unregistered, or PayloadTooLarge. B. Or should we remove the token from the server? That then requires app to re-register the token. But the problem with that is: When I went into App's settings from OS settings and toggled push notifications to on, the app was not launched into the background nor killed i.e. it requires explicit app launch by the user to re-register itself which isn't ideal... It means a user may turn on notifications from the OS settings and then assume that their push notifications should be back in business, but that won't happen if you toggle things from OS settings.
1
0
145
3w
SendProcessControlEvent:toPid: encountered an error
iPhone 16.0 16.0.2 系统上运行小组件出现问题, 其他系统没有问题 SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.jiduauto.iphone.jdcomiphoneWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=5 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedDescription=The request to open "com.apple.springboard" failed., NSLocalizedFailureReason=Unexpected error type., NSUnderlyingError=0x600002bbd7a0 {Error Domain=BSServiceConnectionErrorDomain Code=3 "XPC error received on message reply handler" UserInfo={BSErrorCodeDescription=OperationFailed, NSLocalizedFailureReason=XPC error received on message reply handler}}, BSErrorCodeDescription=InvalidResponse}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.jiduauto.iphone.jdcomiphoneWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=5 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedDescription=The request to open "com.apple.springboard" failed., NSLocalizedFailureReason=Unexpected error type., NSUnderlyingError=0x600002bbd7a0 {Error Domain=BSServiceConnectionErrorDomain Code=3 "XPC error received on message reply handler" UserInfo={BSErrorCodeDescription=OperationFailed, NSLocalizedFailureReason=XPC error received on message reply handler}}, BSErrorCodeDescription=InvalidResponse}., NSUnderlyingError=0x600002bbd5f0 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=5 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedDescription=The request to open "com.apple.springboard" failed., NSLocalizedFailureReason=Unexpected error type., NSUnderlyingError=0x600002bbd7a0 {Error Domain=BSServiceConnectionErrorDomain Code=3 "XPC error received on message reply handler" UserInfo={BSErrorCodeDescription=OperationFailed, NSLocalizedFailureReason=XPC error received on message reply handler}}, BSErrorCodeDescription=InvalidResponse}}} Domain: DTXMessage Code: 1 User Info: { DVTErrorCreationDateKey = "2024-02-19 08:02:14 +0000"; } System Information macOS Version 13.5.2 (Build 22G91) Xcode 15.0 (22265) (Build 15A240d) Timestamp: 2024-02-19T16:02:14+08:00
3
0
1.6k
3w