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

iOS26 Live Activity always display in Dark Mode
Hi, We design a Live Activity for our app.We find that in iOS26 system, the widget can not display the correct system display model(Light mode or dark mode), always display with dark mode. When our app run in other system ,such as iOS 17, iOS18 ,it work fine. I find other developer had post a topic three month ago , but it seems there is not any new response about the feedback. https://developer.apple.com/forums/thread/799684?answerId=857377022#857377022 Anyone have idea? Thanks . Below is my code template: struct BroadcastLiveActivityBackgroundView: View { @Environment(\.colorScheme) var colorScheme: ColorScheme var body:some View { LinearGradient( stops: [ Gradient.Stop(color: LiveActivityColor.backgroundColors(self.colorScheme).last!, location: 0.00), Gradient.Stop(color: LiveActivityColor.backgroundColors(self.colorScheme).first!, location: 1.00), ], startPoint: UnitPoint(x: 1, y: 0), endPoint: UnitPoint(x: 0.82, y: 1.11) ) } }
1
0
50
12h
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.
1
1
115
1d
Now Playing / Recently Played API
We are using the MPNowPlayingInfoCenter API to provide information to the “Now Playing” system UI. This works as expected, except that when the app is manually terminated, the information is removed from the UI. Our question is: Some apps (for example, Audible) are able to appear in the “Recently Played” section of the UI. This section seems to show a history of apps that previously provided “Now Playing” information but are not currently playing anything. We would like to know which API is used to achieve this behavior.
0
0
47
1w
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
135
1w
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
151
2w
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
266
3w
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
267
3w
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
122
3w
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
63
3w
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
74
3w
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
58
3w
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
69
4w
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
125
Nov ’25