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

Нow to set default values for string array intent field provided dynamically?
Hello everybody! Does anybody know how to set default values for string array intent field provided dynamically? I want to have preset array field values just after widget added I have a simple accessory widget with circular and rectangular representation (the first one is for 1 currency value and the second one is for 3 values). I created CurrencyWidgets.intentdefinition and added AccessoryCurrency custom intent. Here I added string parameter field currencyCode. For this parameter I set the following options: Supports Multiple Values Fixed Size (AccessoryCircular = 1, AccessoryRectangular = 3) User can edit value in Shortcuts Options are provided dynamically Then I created CurrencyTypeIntent extension and added IntentHandler for my custom intent AccessoryCurrency. The code is below class IntentHandler: INExtension, AccessoryCurrencyIntentHandling { override func handler(for intent: INIntent) -> Any { self }     func provideCurrencyCodeOptionsCollection(for intent: AccessoryCurrencyIntent) async throws -> INObjectCollection<NSString> {         return INObjectCollection(items: [NSString("USD"), NSString("EUR"), NSString("RUB"), NSString("CNY")])    } func defaultCurrencyCode(for intent: AccessoryCurrencyIntent) -> [String]? {      return ["USD", "EUR", "RUB"]    } } The problem is in func defaultCurrencyCode(...): when I return something except nil (for example ["USD"] or ["USD", "EUR", "RUB"]) then I got a broken widget. It hangs in a placeholder state in lock screen and at add widget UI (see the image below). Otherwise when I return nil then my widget works fine. But when I try to customise widget then I don't have default values for my currencyCode field, only Chose placeholders. At the same time everything works fine for the single string parameter (without "Supports Multiple Values"). Does anybody know how to make default parameters work for array (multiple) field?
0
0
138
3w
Local Updates to Live Activities ignored after push update
I'm building out a live activity that has a button which is meant to update the content state of the Live Activity. It calls a LiveActivityIntent that runs in the app process. The push server starts my live activity and the buttons work just fine. I pass the push token back to the server for further updates and when the next update is pushed by the server the buttons no longer work. With the debugger I'm able to verify the app intent code runs and passes the updated state to the activity. However the activity never updates or re-renders. There are no logs in Xcode or Console.app that indicates what the issue could be or that the update is ignored. I have also tried adding the frequent updates key to my plist with no change. I'm updating the live activity in the LiveActivityIntent like this: public func perform() async throws -> some IntentResult { let activities = Activity<WidgetExtensionAttributes>.activities for activity in activities { let currentState = activity.content.state let currentIndex = currentState.pageIndex ?? 0 let maxIndex = max(0, currentState.items.count - 1) let newIndex: Int if forward { newIndex = min(currentIndex + 1, maxIndex) } else { newIndex = max(currentIndex - 1, 0) } var newState = currentState newState.pageIndex = newIndex await activity.update( ActivityContent( state: newState, staleDate: nil ), alertConfiguration: nil, timestamp: Date() ) } return .result() } To sum up: Push to start -> tap button on activity -> All good! Push to start -> push update -> tap button -> No good...
3
0
80
6h
TUINSRemoteViewController over-release crash in ViewBridge during autorelease pool drain
Summary A crash occurs in ViewBridge framework when a TUINSRemoteViewController object receives -release message after being deallocated. This appears to be a reference counting issue within the ViewBridge framework's internal autorelease pool management. Environment macOS Version: [15.0.0] Application: Custom Qt-based application using Chromium Embedded Framework (xcode version: xcode 15; QT version: 6.5.4 ; CEF version: 138.0.47+g2728d53+chromium-138.0.7204.221) Steps to Reproduce Users are typically using the app normally, but a crash occasionally occurs when they activate and click on the application. This happens infrequently, but it occurs roughly every day. Currently, only a few specific users experience this crash, and it may appear for several consecutive days before disappearing for several days. We cannot reliably reproduce this issue but have collected crash logs from affected users. Crash Analysis Zombie Detection Log: Zombie <TUINSRemoteViewController: 0x338708020> received -release Deallocation Stack Trace (when object was first released): 0 Chromium Embedded Framework 0x000000014283a7f4 rust_png$cxxbridge1$ResultOfWriter$operator$sizeof + 933592 1 AppKit 0x000000019eac0d80 -[NSResponder dealloc] + 340 2 AppKit 0x000000019ebb5e34 -[NSViewController dealloc] + 276 3 ViewBridge 0x00000001a3f6ab9c -[NSRemoteViewController dealloc] + 92 4 AppKit 0x000000019eada4b4 -[NSViewController release] + 236 5 ViewBridge 0x00000001a3eda130 -[NSRemoteViewController release] + 380 6 libobjc.A.dylib 0x000000019aa8806c objc_autoreleasePoolPop + 56 7 CoreFoundation 0x000000019aefc7c0 _CFAutoreleasePoolPop + 32 8 Foundation 0x000000019c0d14f4 -[NSAutoreleasePool drain] + 136 9 ViewBridge 0x00000001a3ed609c __CONSIDER_WHO_REQUESTED_THIS_WAIT_BEFORE_SENDING_BUG_TO_VIEWBRIDGE__ + 24 10 ViewBridge 0x00000001a3f82a10 deferredBlockOpportunity_block_invoke_2 + 436 11 CoreFoundation 0x000000019af3dfa0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 12 CoreFoundation 0x000000019af3deb0 __CFRunLoopDoBlocks + 356 13 CoreFoundation 0x000000019af3d330 __CFRunLoopRun + 2432 14 CoreFoundation 0x000000019af3c334 CFRunLoopRunSpecific + 572 15 HIToolbox 0x00000001a63740cc RunCurrentEventLoopInMode + 292 16 HIToolbox 0x00000001a6379ebc ReceiveNextEventCommon + 636 17 HIToolbox 0x00000001a637a020 _BlockUntilNextEventMatchingListInModeWithFilter + 76 18 AppKit 0x000000019ea7fa70 _DPSNextEvent + 660 19 AppKit 0x000000019f3a57b8 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688 Crash Stack Trace (second release attempt): 0 Chromium Embedded Framework 0x14a03a37c rust_png$cxxbridge1$ResultOfWriter$operator$sizeof + 932448 1 Chromium Embedded Framework 0x14a03a04c rust_png$cxxbridge1$ResultOfWriter$operator$sizeof + 931632 2 CoreFoundation 0x19af1cbe8 ___forwarding___ + 200 3 CoreFoundation 0x19af1ca60 _CF_forwarding_prep_0 + 96 4 libobjc.A.dylib 0x19aa8bd94 AutoreleasePoolPage::releaseUntil(objc_object**) + 204 5 libobjc.A.dylib 0x19aa88138 objc_autoreleasePoolPop + 260 6 CoreFoundation 0x19aefc7c0 _CFAutoreleasePoolPop + 32 7 Foundation 0x19c0d14f4 -[NSAutoreleasePool drain] + 136 8 ViewBridge 0x1a3ed609c __CONSIDER_WHO_REQUESTED_THIS_WAIT_BEFORE_SENDING_BUG_TO_VIEWBRIDGE__ + 24 9 ViewBridge 0x1a3f82a10 deferredBlockOpportunity_block_invoke_2 + 436 10 CoreFoundation 0x19af3dfa0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 11 CoreFoundation 0x19af3deb0 __CFRunLoopDoBlocks + 356 12 CoreFoundation 0x19af3d330 __CFRunLoopRun + 2432 13 CoreFoundation 0x19af3c334 CFRunLoopRunSpecific + 572 14 HIToolbox 0x1a63740cc RunCurrentEventLoopInMode + 292 15 HIToolbox 0x1a6379ebc ReceiveNextEventCommon + 636 16 HIToolbox 0x1a637a020 _BlockUntilNextEventMatchingListInModeWithFilter + 76 17 AppKit 0x19ea7fa70 _DPSNextEvent + 660 18 AppKit 0x19f3a57b8 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688 19 AppKit 0x19ea72b7c -[NSApplication run] + 480 20 libqcocoa.dylib 0x1057b7514 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2156 21 QtCore 0x109bb55c4 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 532 22 QtCore 0x109babff8 QCoreApplication::exec() + 112 23 HoYowave 0x1009fc740 QWidgetFrameAdapter::RunMessageLoop() + 132 24 HoYowave 0x1008ae908 0x10088c000 + 141576 25 HoYowave 0x1008b7038 0x10088c000 + 176184 26 HoYowave 0x1008a3544 0x10088c000 + 95556 27 HoYowave 0x1008a294c 0x10088c000 + 92492 28 dyld 0x19aad4274 start + 2840 Technical Analysis The crash pattern indicates: A TUINSRemoteViewController was autoreleased multiple times During autorelease pool drain, the first release triggered dealloc Subsequent release attempts accessed the deallocated object (zombie) This is entirely within ViewBridge framework's internal code path The function name __CONSIDER_VIEW_SERVICE_BEFORE_SENDING_BUG_TO_VIEWBRIDGE__ in the stack trace suggests this is a known problematic area. Questions Is this a known issue in ViewBridge framework? Is there any workaround or mitigation we can apply from the application side? Could you provide guidance on what might trigger this condition? I have report this in Feedback Assistant FB21809243
0
0
24
5d
Live Activities widget extension does not reflect updated SwiftUI UI (custom views/assets appear ignored)
Hello Apple Developer Technical Support, I’m following up on case #102807413324 and submitting this as a code-level support request. We are integrating iOS Live Activities (ActivityKit + WidgetKit extension written in SwiftUI) into an Expo/React Native app. We’re seeing behavior where the Live Activity UI shown on the Lock Screen appears to “stick” to an older layout and ignores updated SwiftUI code and/or bundled assets, even after rebuilding, reinstalling, and removing existing Live Activities before testing again. Environment Device: iPhone 13 iOS: 26.2 macOS: 15.7.3 (24G419) Xcode: 16.4 (16F6) Expo SDK: 52 React Native: 0.76.9 expo-live-activity: ^0.4.2 Build type: Ad-Hoc signed IPA (EAS local build) Summary We have a WidgetKit extension target (LiveActivity.appex, bundle id: stimul8.LiveActivity) using ActivityConfiguration(for: LiveActivityAttributes.self). The extension contains multiple SwiftUI views selected via a “route” (derived from deepLinkUrl / title / subtitle), and uses images/backgrounds from the extension asset catalog (Assets.xcassets). We also support loading images from an App Group container with a fallback to the asset catalog. After shipping updates, the Live Activity UI shown on the Lock Screen continues to resemble an older/default layout (example: a progress-bar-like element remains visible even after removing ProgressView usage from LiveActivityView.swift). Some custom backgrounds/images also fail to display as expected. Routing (examples) /streak -> StreakLiveActivityView /streak-urgent -> StreakUrgentLiveActivityView /lesson/create -> AILessonLiveActivityView1 /lesson/reminder -> AILessonLiveActivityView2 default -> LiveActivityView Steps to reproduce (high-level) Install/build and trigger a Live Activity. Modify the SwiftUI layout in the extension (e.g., remove ProgressView and change obvious UI elements), rebuild, and reinstall. Remove any existing Live Activities from the Lock Screen, then trigger a new Live Activity again. Observed: Lock Screen Live Activity still renders the prior/older-looking UI and/or ignores updated assets. Troubleshooting already done Verified the extension (LiveActivity.appex) is included in the IPA and properly signed. Verified Assets.car is present in the extension and PNG assets are present in the build artifacts. Ensured SwiftUI source files used by the extension are overwritten during prebuild so the intended versions are present in ios/LiveActivity. Cleared DerivedData related to LiveActivity builds. Reinstalled the app and removed existing Live Activities from the Lock Screen before re-triggering new ones. Questions Is there any known caching behavior where Live Activities can continue to display a previous UI layout after an app/extension update, even when the activity is re-created? Are there recommended steps to force the system to load the newest widget extension binary/UI beyond reinstalling and removing existing Live Activities? What’s the recommended way to confirm which exact extension binary/UI version is being rendered on-device (e.g., specific Console logs, sysdiagnose signals, or other indicators)? Are there any known constraints with Assets.xcassets usage for Live Activities that could cause bundled assets not to render even when present? We can provide A minimal reproduction Xcode project (preferred) The IPA build Build logs (Xcode/EAS) Screenshots/video and a sysdiagnose captured after reproduction Thank you for your guidance. Best regards
0
0
17
2d
Widget & Snapshot Blank on iOS 26
Some of the users of my app reported that, the widgets cannot be loaded, event after restarts and re-installs. It seems that it is not rare, I have tens of reports on this (and probably much more who didn't report). It seems the widget is blank even on the gallery screen while you are first adding it: struct SingleWidgetProvider: AppIntentTimelineProvider { @Environment(\.widgetFamily) var family private let viewModel: WidgetViewModel = WidgetViewModel() func placeholder(in context: Context) -> SingleEntry { SingleEntry(date: Date(), habit: .singleSample) } func snapshot(for configuration: SingleWidgetConfigurationIntent, in context: Context) async -> SingleEntry { guard let habit = Array(PersistenceManager.shared.retrieveHabitList().habits).first else { return SingleEntry(date: Date(), habit: .singleSample) } let displayable = viewModel.displayableFromHabit(habit, separateComponents: true, secondOffset: 0) return SingleEntry(date: Date(), habit: displayable) } func timeline(for configuration: SingleWidgetConfigurationIntent, in context: Context) async -> Timeline<SingleEntry> { var entries: [SingleEntry] = [] guard let counter = configuration.currentCounter else { return Timeline(entries: [SingleEntry(date: Date(), habit: .singleSample)], policy: .atEnd) } guard let habit = PersistenceManager.shared.retrieveHabit(habitKey: counter.id) else { return Timeline(entries: [SingleEntry(date: Date(), habit: .singleSample)], policy: .atEnd) } let currentDate = Date() for secondOffset in 0 ..< 100 { let displayable = viewModel.displayableFromHabit( habit, separateComponents: true, secondOffset: secondOffset, symbolName: habit.habitSymbol?.name ?? "", overrideColor: configuration.currentColor.color, overrideButtonVisibility: configuration.currentButtonVisibility, overrideDisplayOption: configuration.currentDisplayOption ) let entryDate = Calendar.current.date(byAdding: .second, value: secondOffset, to: currentDate)! let entry = SingleEntry(date: entryDate, habit: displayable) entries.append(entry) } return Timeline(entries: entries, policy: .atEnd) } } struct SingleEntry: TimelineEntry { let date: Date let habit: HabitDisplayable } static var singleSample: HabitDisplayable { return HabitDisplayable(habitKey: nil, title: LS("sampleWidgetHabitTitle"), dates: [Date(timeIntervalSince1970: 1507158360)], displayOption: .dayMonthYear, secondOffset: 0, separateComponents: true) } func displayableFromHabit( _ habit: Habit, separateComponents: Bool, secondOffset: Int, symbolName: String = "", overrideColor: Color? = nil, overrideButtonVisibility: WidgetButtonVisibility? = nil, overrideDisplayOption: WidgetDisplayOption? = nil ) -> HabitDisplayable { let latestDates: [HabitDate] let displayOption: DisplayOption if let overrideDisplayOption { if overrideDisplayOption == .sameAsCounter { displayOption = habit.settings?.toValue.displayOption ?? .dayMonthYear } else { displayOption = DisplayOption(rawValue: overrideDisplayOption.rawValue - 1) ?? .dayMonthYear } } else { displayOption = habit.settings?.toValue.displayOption ?? .dayMonthYear } let displayMode = displayOption.mode switch displayMode { case .timePassed, .date: latestDates = PersistenceManager.shared.latestDate(habit: habit).map { [$0] } ?? [] case .activity: latestDates = PersistenceManager.shared.retrieveHabitDates(habit: habit, limitDate: displayOption.limitDate()) } let displayButton: Bool if let overrideButtonVisibility { if overrideButtonVisibility == .sameAsCounter { displayButton = habit.settings?.toValue.buttonType == .onRow } else { displayButton = overrideButtonVisibility == .show } } else { displayButton = false } return HabitDisplayable( habitKey: habit.habitKey, title: habit.title, dates: latestDates.map { $0.date }, displayOption: displayOption, secondOffset: secondOffset, separateComponents: separateComponents, color: overrideColor ?? habit.habitColor?.color ?? .appPrimary, symbolName: symbolName, displayButton: displayButton ) } I provided a large portion of my code, let me know if you need more. The strange thing here is, even if the DB connection is broken somehow, it should have shown the default option (singleSample). I am not able to reproduce/fix this for months now, so any help is very appreciated.
1
0
39
2d
Intended Flow of Invalidating the pushToStartToken When User Logs Out
Hi, we start and update Live Activities with ActivityKit push notifications in our app, but want to do so only if the user is logged in. Therefore we only send the pushToStartToken to the server when a user logs in (or when the token changed and the user is still logged in.) When the user logs out, we remove that start token from our server so that no LA can be started while the app is in the logged out state. This means that the logout isn't happening immediately but is waiting for that deletion request to succeed. This could also fail and lead to the use rnot being able to log out, e.g. if the user has no internet access. If that deletion request would be fire and forget, we would end up in a state where the server still has the token and might start LAs without any user being logged in. The token flow for Remote Push Notifications is different, on the other hand: requesting a token asynchronously via UIApplication.shared.registerForRemoteNotifications() but invalidating it synchronously (at least from the app's perspective) on logout via UIApplication.shared.unregisterForRemoteNotifications(), which makes it way easier for us to make sure the app does not get notifications when no user is logged in. We're wondering if we're just holding it wrong or if our way of handling the LA token deletion is indeed the intended one?
0
0
14
9h
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.8k
Nov ’25
Can't load widget with a particular bundle id on Catalyst
Please note that the widgets sub forum is a 404: https://developer.apple.com/forums/post/question?community=1394020 I have a widget that works on iOS but doesn't work on Catalyst. The widget does not appear in the list of available widgets to install. It's related to the Bundle ID for the widget. If I use a fresh bundle ID the widget loads, but if I use the one I'm currently using for iOS it doesn't appear as available to install. To confirm it's related to the bundle ID I created a fresh project in xcode and recreated the behaviour. Any help greatly appreciated.
4
0
222
May ’25
AccessibilityNode not working in Unity?
Hi, I have a class project I am working on (with a due date tomorrow, unfortunately RIP to me). But I have made my project about adding accessibility to a Unity game. I've successfully added apple unity core and accessibility plugins to my project, and my project builds. But I have simple text nodes and buttons and they aren't accessible with voiceover once I build/export my game and test. I am only building for MacOS right now (for the assignment). I don't have too much experience with Unity, but I am relatively experienced with accessibility (even formerly an intern and contractor at Apple for accessibility). So I wonder if I am just using Unity incorrectly? Perhaps I've done something to my build process (or haven't done something I should)? I've attached a photo of what my dev environment looks like in Unity, I've focused a text node (on the left) and on the right are my AccessibilityNode settings. Any help would be awesome, even if I don't make my deadline tomorrow... :*( Project repo is here, if it is helpful: https://github.com/frankelavsky/PGD_final_project Thanks!
2
0
194
Apr ’25
Strange Live Activity Occurrence Behavior
I am seeing a really weird behavior with Live Activities. The Live Activity is always appearing on the simulator. However the Live Activity is only appearing on my physical device when there is no other widget in the widget bundle shown below. @main struct HoerspielWidgetsBundle: WidgetBundle { var body: some Widget { // Uncomment the line below and the Live Activity will no longer appear // UpNextWidget() PlaybackLiveActivity() } } Annotating that var with @WidgetBundle has no effect. There are no logs indicating an error, the function to request a Live Activity does not throw and the status of the activity is active. Both the widget and the Live Activity are working fine otherwise. NSSupportsLiveActivities is set to true in the correct Info.plist file. I am not running any beta software and the physical iPhone is on the newest version (iOS 18.5). Using the template when adding a new target in Xcode, I was able to set up a similar app where the Live Activity works as expected. I am really at a loss here which additional information I should provide or how this issue can be resolved. Thank you for your help.
2
0
150
May ’25
Location streaming onto Live Activity
Hello forum, I want to keep my app running in the background after user swaps up, for the purpose of workout tracking. start up the task and continuously receipt GPS updates process the location data show the data on a live activity Two examples Strava paddlelogger Question: Does this mean, these two apps would just pause when the .backgroundTimeRemaining becomes 0? How does a workout app "work" in background mode, do I need to handle budget running out?
2
0
123
Jun ’25
Effective use of .disfavouredLocations API
I have a Health & Fitness widget that runs on iPhone and Apple Watch. As Health data access requires the device to be unlocked, the iPhone widget is already slightly limited in capability because of updates. With widgets further expanding to places like CarPlay, I know I can use the .disfavouredLocations{} API to try and prevent it being offered there. This is crucial as the widget functionality would be basically non-existent as your device is locked during CarPlay use. My problem is, on the Mac despite using the .disfavouredLocations{.iPhoneWidgetsOnMac} etc...., the widget can still be added in the "other unsupported section". And yet, in that section the Apple Fitness app widget is no where to be seen. Is there an API I am missing to completely remove a widget from the Mac widget gallery and hopefully CarPlay, Standby etc.... (all places where the device running the widget is usually locked -> No Health data)? Or does the Apple Fitness app have a private API to block it from these places where its function is not wanted and this isn't available to other apps?
1
0
136
Jun ’25
Widget Previews in visionOS 26 Beta (Xcode 26 Beta)
Hello, I'm currently developing for visionOS using Xcode's latest beta version. I have a question regarding Widget Previews for visionOS 26: When I create a new Widget Extension target directly from a visionOS project, the generated code does not include the #Preview macro. Following the documentation, I manually added the #Preview macro to a Widget created within a visionOS project, but Xcode then displays an error stating that "This platform does not support previewing widgets." My interpretation is that Widget Previews are currently not supported for Widgets created specifically for visionOS in this beta version. Is this understanding correct? Or am I missing a specific way to implement previews for visionOS Widgets, or is there a particular project setting I might have overlooked? Any clarification or guidance on this matter would be greatly appreciated. Thank you.
1
0
162
Jun ’25
Update Complications in WatchOS from iOS using WatchConnectivity?
I'm trying to update data displayed in my Watch Complications (WidgetKit). I have an iOS app that sends data to the Apple Watch using WCSession.default.transferUserInfo. However, the data only updates on the complications or widgets after I open the watchOS app manually. Ideally, I'd like the Watch widget/complication to reflect the updated data as soon as it's sent from the iPhone, without requiring the user to open the Watch app.
1
0
381
Jun ’25
SwiftData changes made in widget via AppIntent are not reflected in main app until full relaunch
Hi, I’m using SwiftData with an @Observable DatabaseManager class that is shared between my app and a widget. This class is located inside a Swift package and looks roughly like this: public final class DatabaseManager { public static let shared = DatabaseManager() private init() { let groupID = "group.com.yourcompany.myApp" let config = ModelConfiguration(groupContainer: .identifier(groupID)) let c = try! ModelContainer(for: MyModel.self, configurations: config) self.container = c self.modelContext = c.mainContext } public private(set) var container: ModelContainer public private(set) var modelContext: ModelContext } In the main app, I inject the container and context like this: struct MyApp: App { var body: some Scene { WindowGroup { ContentView() .modelContainer(DatabaseManager.shared.container) .modelContext(DatabaseManager.shared.modelContext) } } } Both the widget and the main app import the same package, and both use DatabaseManager.shared for reading and writing objects. The problem: When the widget updates an object using an AppIntent, the change is not reflected in the main app unless I fully terminate and relaunch it. If I just bring the app back to the foreground, it still shows stale data. Is there a recommended way to make the main app observe or reload SwiftData changes that were made in the widget (via the same shared app group and container)? I’m already using .modelContainer(...) and .modelContext(...) in the app, and everything else works fine — it’s just the syncing that doesn’t happen unless I force-relaunch the app. Thanks!
2
0
300
Jul ’25
Large Gap Between Published and Delivered Broadcast Notifications for Live Activities in iOS 18
Hi All, I’m working on a football live score app with Dynamic Island support, using iOS 18 Broadcast Notifications for Live Activities. Our workflow is: We use the Push-to-Start token to initiate the Live Activity. For updates, we use the Channel ID. Start, update, and end events for Live Activities are all handled via remote notifications. We tested on 3-4 devices simultaneously, but noticed inconsistent UI updates: some devices update properly while others do not, even when using the same Channel ID. Checking the notification console dashboard, last week we had around 1,397 notifications published but only 555 delivered — a significant discrepancy. All devices are active and connected to reliable internet, so we’re unsure why delivery rates are so low. Additional details: For the start event, we set notification priority to 10. For updates, we lowered priority to 5 per Apple’s documentation, to reduce throttling. This adjustment improved the situation compared to sandbox testing where all notifications were priority 10. Despite this, during weekend matches, we observed a drastic drop: out of 140 published notifications, only 2 were delivered. This large delivery gap risks missing critical update deadlines in our app. Could anyone help us understand what might be causing this and how to improve notification delivery reliability? Thanks in advance!
1
0
100
Jul ’25
Generating token using pushToStartTokenUpdates in terminated state
Pretty much the title. I am a noob in apple app development and currently starting it out. I got stuck in this. Can anyone let me know that how can i generate the token for starting live activity in terminated state? I have tried multiple times to find that this one is not working in terminated state. How can I overcome this? Is there any solution or workaround?
3
0
208
Jul ’25
How to automatically set the `timestamp` field for Live Activity updates events?
I know for start events, sending the timestamp isn't required. So that's easy. However when I'm testing Live Activity using the Apple Push Notification Console. A lot of times I just need to copy/paste the payload and resend it again. But then the timestamp field needs to get updated each time, because if it's from a time in the past, then it won't trigger. This requires me to have to use an EPOCH converter to find the right time and then copy/paste it. Is there a better solution to this? I know I can use curl, but that is not in the scope of my question.
1
0
94
Jul ’25