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!
Widgets & Live Activities
RSS for tagDiscuss how to manage and implement Widgets & Live Activities.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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!
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?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
iOS
iPhone
Notification Center
WidgetKit
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.
I am building a widget that supports 2 different widget kinds, each supporting systemSmall, systemMedium, and systemLarge size families.
My widget does download and display images so I expect memory usage to be on the higher end, but in debugging some memory issues, I notice that when I build my widget scheme to a physical device, things start off reasonable at ~12MB of memory usage. But as I change the widgets intent, add the other widget kind, or add different widget size families, this memory usage grows until it ultimately hits the 30MB cap.
My question is, is the 30MB memory limit spread across all my supported widget kinds/sizes? Or does each individual widget get its own 30MB cap?
i.e., if I have systemMedium Widget A and systemLarge Widget B, are they sharing that 30MB memory limit?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
Extensions
Instruments
Debugging
WidgetKit
Hi Apple team,
I'm experiencing a persistent issue with writing to UserDefaults from a widget extension on iOS. Here's the situation:
I've set up an App Group: group.test.blah
The main app has the correct entitlement and can read/write from UserDefaults(suiteName:) using this group successfully.
I can read the value written by the app from the widget (e.g., "testFromApp": "hiFromApp").
The widget extension has the same App Group enabled under Signing & Capabilities.
The provisioning profile reflects the App Group and the build installs successfully on a real device.
The suite name is correct and matches across both targets.
I’ve confirmed via FileManager.default.containerURL(...) that the app group container resolves properly.
When I try to write from the widget extension like this
let sharedDefaults = UserDefaults(suiteName: "group.test.blah")
sharedDefaults?.set("hiFromWidget", forKey: "testFromWidget")
...I get this error in the console:
Couldn't write values for keys (
testFromWidget
) in CFPrefsPlistSource<0x1140d2880> (Domain: group.test.blah, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
Questions:
What could still cause the widget extension to lack write access to the app group container, even though it reads just fine?
Are there any internal sandboxing nuances or timing-related issues specific to Live Activity widgets that could explain this?
Is this a known limitation or platform issue?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
Extensions
Entitlements
ActivityKit
Files and Storage
I am currently developing an interactive widget, but an AppIntent issue blocked me for 2 days.
I have an AppIntent named TimerActionIntent, which has two parameters: TimerType and TimerAction. Here is the code:
import AppIntents
enum TimerType: Int, CaseIterable, AppEnum, AppEntity {
case sleep
case feeding
static let typeDisplayRepresentation: TypeDisplayRepresentation = "Timer Type"
static let caseDisplayRepresentations: [TimerType : DisplayRepresentation] = [
.sleep: "Sleep",
.feeding: "Feeding"
]
}
enum TimerAction: Int, CaseIterable, AppEnum, AppEntity {
case start
case pause
case stop
static let typeDisplayRepresentation: TypeDisplayRepresentation = "Timer Action"
static let caseDisplayRepresentations: [TimerAction : DisplayRepresentation] = [
.start: "Start",
.pause: "Pause",
.stop: "Stop"
]
}
struct TimerActionIntent: AppIntent {
static let title: LocalizedStringResource = "Operate a Log Timer"
@Parameter(title: "Timer", default: .sleep)
var timerType: TimerType
@Parameter(title: "Action", default: .start)
var action: TimerAction
static var isDiscoverable: Bool = false
static var openAppWhenRun: Bool = false
init() {}
init(timerType: TimerType, action: TimerAction) {
self.timerType = timerType
self.action = action
}
func perform() async throws -> some IntentResult {
// perform the action
Self.openAppWhenRun = state == .stopped
}
return .result()
}
}
I can't execute the AppIntent if using the following code:
Button(intent: TimerActionIntent(timerType: .sleep, action: .start)) {
// button view
}
// or
let intent = TimerActionIntent()
intent.timerType = timerType
intent.action = .start
Button(intent: intent) {
// button view
}
and only execute when initialize TimerActionIntent without any parameters and @Parameter has the default value. e.g.
Button(intent: TimerActionIntent()) {
// button view
}
I have some logs in the Console app:
default 17:51:27.626382+0800 linkd Accepting XPC connection from PID 39255 for service "com.apple.linkd.registry"
default 17:51:27.637511+0800 WidgetsExtension Beginning PerformAction <<SB:788D850BBBC5>>
default 17:51:27.637540+0800 WidgetsExtension Beginning InitializeAction <<SB:ACBC7A27CCBF>>
default 17:51:27.637556+0800 WidgetsExtension [InitializeAction <<N:ACBC7A27CCBF>>] Found TimerActionIntent matching TimerActionIntent registered with AppManager
default 17:51:27.637725+0800 WidgetsExtension Prepared timerType to TimerType(TimerType/0))
default 17:51:27.637744+0800 WidgetsExtension Prepared action to TimerAction(TimerAction/0))
default 17:51:27.637772+0800 WidgetsExtension Ending InitializeAction <<SE:ACBC7A27CCBF>>
default 17:51:27.637795+0800 WidgetsExtension Beginning ResolveParameters <<SB:6C7CA02308AD>>
default 17:51:27.639807+0800 WidgetsExtension Building resolver for parameter timerType<TimerType> = TimerType/0
default 17:51:27.640160+0800 WidgetsExtension Building resolver: EntityIdentifier → TimerType:TimerActionIntent:timerType
default 17:51:27.640202+0800 WidgetsExtension Ending ResolveParameters <<SE:6C7CA02308AD>>
default 17:51:27.640221+0800 WidgetsExtension Beginning NeedsDisambiguation <<SB:8E482F9CCCB0>>
default 17:51:27.641328+0800 WidgetsExtension Ending NeedsDisambiguation <<SE:8E482F9CCCB0>>
default 17:51:27.641344+0800 WidgetsExtension Ending PerformAction <<SE:788D850BBBC5>>
error 17:51:27.642316+0800 chronod Perform action connection operation completed with error: Error Domain=LNActionExecutorErrorDomain Code=2010 "(null)"
error 17:51:27.642774+0800 chronod Operation `<LNPerformActionConnectionOperation: 0x600002c4a180, identifier: F8FB77C5-7F8A-4670-BB8C-465DE4EAB6B8>` error Error Domain=LNActionExecutorErrorDomain Code=2010 "(null)"
default 17:51:27.643358+0800 linkd Invalidated XPC connection from PID 39255 for service "com.apple.linkd.registry"
I can't find any details about the error " Error Domain=LNActionExecutorErrorDomain Code=2010 "(null)""
The environment:
Xcode: 16.4/26 beta 5
iOS: iOS Simulator 18.5, iOS Simulator 26, iPhone 16 Pro Max 18.6
macOS 15.6
Can anyone help me, please!
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
I'm developing an app which will show the driver ETA and rendering the progress bar of the current ETA.
Intuitively the backend server sends the push notification every 3 seconds through firebase cloud message service to APNS so that the device can refresh the dynamic island smoothly.
But the live activity doesn't refresh as frequently as the backend service does.
It should refresh every 3 seconds but it turns out like refresh 30 ~ 60 seconds, sometimes it didn't refresh at all.
any body facing the same?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
APNS
User Notifications
ActivityKit
The docs are conflicting.
https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications#End-the-Live-Activity-with-a-custom-dismissal-date says:
When you end a Live Activity, by default the Live Activity appears on the Lock Screen for up to four hours after it ends to allow people to glance at their phone to refer to the latest information.
However here it says:
https://developer.apple.com/documentation/activitykit/displaying-live-data-with-live-activities#Understand-constraints
A Live Activity can be active for up to eight hours unless its app or a person ends it before this limit. After the eight-hour limit, the system automatically ends the Live Activity, and immediately removes it from the Dynamic Island. However, the Live Activity remains on the Lock Screen until a person removes it or for up to four additional hours before the system removes it — whichever comes first. As a result, a Live Activity remains on the Lock Screen for a maximum of 12 hours.
So is it 4 hrs OR '8 for Dynamic Island vs 12 for Lock Screen'?
Hi everyone, I'm using an app group to share data between iOS and it's watch companion app.
I ensured that is has the same identifier in Signing & Capabilities and in the .entitlements files.
Here is the UserDefaults part:
class UserDefaultsManager {
private let suitName = "group.com.sanjeevbalakrishnan.Test"
public func saveItems(_ items: [ItemDTO]) {
print("Save \(items.count) items to shared defaults")
let defaults = UserDefaults(suiteName: suitName)
let data = try? JSONEncoder().encode(items)
defaults?.set(data, forKey: "items")
}
public func loadItems() -> [ItemDTO] {
let defaults = UserDefaults(suiteName: suitName)
print(defaults)
guard let data = defaults?.data(forKey: "items") else {
print("watchOS received data is empty")
return []
}
let items = [ItemDTO].from(data: data)
print("Load \(items.count) items from user defaults")
return items
}
}
For testing I called loadItems after saveItems on iOS app and it returned items. However, on watchOS app it always returns empty array.
What do I need to consider?
Thanks.
Best regards
Sanjeev
Hi there,
I'm using WCSession to communicate watchOS companion with its iOS app.
Every time watch app becomes "active", it needs to fetch data from iOS app, which works e.g. turning my hand back and forth.
But only when the app is opened after it was minimised by pressing digital crown, it didn't fetch data. My assumption is that scenePhase doesn't emit a change on reopen.
Here is the ContentView of watch app:
import SwiftUI
struct ContentView: View {
@EnvironmentObject private var iOSAppConnector: IOSAppConnector
@Environment(\.scenePhase) private var scenePhase
@State private var showOpenCategories = true
var body: some View {
NavigationStack {
VStack {
if iOSAppConnector.items.isEmpty {
WelcomeView()
} else {
ScrollView {
VStack(spacing: 10) {
ForEach(iOSAppConnector.items, id: \.self.name) { item in
ItemView(item: item)
}
}
}
.task {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
loadItems()
}
}
.onChange(of: scenePhase, initial: true) { newPhase, _ in
if newPhase == .active {
loadItems()
}
}
}
fileprivate func loadItems() -> Void {
if iOSAppConnector.items.isEmpty {
iOSAppConnector.loadItems()
}
}
}
What could be the issue?
Thanks.
Best regards
Sanjeev
Live Activity: no value in pushTokenUpdates and pushToStartTokenUpdates not called after app restart
When running application after installation I get a value in pushTokenUpdates and also the call to pushToStartTokenUpdates returns with the token value.
But, if I kill the app and restart it again, there is no value in pushTokenUpdates and the call to pushToStartTokenUpdates does not return.
Am I suppose to use the push to start token from the previous application run?
is there a different solution?
Hello everyone,
I'm developing an app for iOS 18 using SwiftData, with iCloud synchronization enabled. My app also includes an interactive widget that allows users to mark tasks as complete, similar to Apple's Reminders widget.
I'm facing a specific issue with how iCloud sync is triggered when changes are made from the widget.
My Setup:
Xcode 16
Swift 6 / iOS 18
SwiftData with iCloud Sync enabled.
An interactive widget using App Intents to modify the SwiftData model.
What's working correctly:
App to Widget (Same Device): If I mark a task as complete in the main app, the widget on the same device updates instantly.
Widget to App (Same Device): If I mark a task as complete using the interactive widget, the main app on the same device reflects this change immediately.
App to App (Across Devices): If I make a change in the app on my iPhone, it syncs correctly via iCloud and appears in the app on my iPad.
The Problem:
The synchronization issue occurs specifically when an action is initiated from the widget and needs to be reflected on other devices, or when a change from another device needs to be reflected in the widget.
Widget Change Not Syncing to Other Devices: If I mark a task as complete in the widget on my iPhone, the change does not sync to my iPad. The task on the iPad only updates after I manually open the main app on the iPhone.
Remote Change Not Syncing to Widget: Similarly, if I mark a task as complete in the app on my iPad, the widget on my iPhone does not update to show this change. The widget only refreshes with the correct state after I open the main app on the iPhone.
It seems that the widget's AppIntent correctly modifies the local SwiftData store, but this action isn't triggering the necessary background process to push the changes to iCloud. The sync only seems to happen when the main app, with its active ModelContainer, is brought to the foreground.
My goal is for any change made in the widget to be reflected across all of the user's devices in near real-time, without requiring them to launch the main app to initiate the sync.
Is there a specific API I need to call from my AppIntent to force a SwiftData sync, or a project capability I might be missing to allow the widget extension to trigger iCloud pushes?
Any help or guidance would be greatly appreciated.
Thank you!
Project structure is:
App target + widget extension + widget intent extension
All share a common appgroup group.com.x.y and all file handling is done using
FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.x.y")
so that only the shared container is used.
Using the Main app target, a font "Chewy-Regular.ttf" is downloaded and saved to the shared AppGroup container.
Font can now be loaded via
CTFontManagerRegisterFontsForURL
and displayed in a Main App Text view
Text("Testing...").font(Font.custom("Chewy-Regular", size: 20))
Now add a Widgetkit widget instance that uses this font.
In 'getTimeLine() and getSnapShot() of IntentTimelineProvider we load the font again via CTFontManagerRegisterFontsForURL (this needs to happen again probably because widget runs in a separate process from the main app?).
On simulator, the widget will show the correct font.
BUT
On iPhone7 real device, the widget will show the 'redacted placeholder view'. It seems that something is crashing.
I see in the device console :
error 14:39:07.567120-0800 chronod No configuration found for configured widget identifier: D9BF75EE-4A04-441A-8C85-1507F7ECE379
fault 14:39:07.625600-0800 widgetxExtension -[EXSwiftUI_Subsystem beginUsing:withBundle:] unexpectedly called multiple times.
error 14:39:07.672733-0800 chronod Encountered an error reading the view archive for &lt;private&gt;; error: &lt;private&gt;
error 14:39:07.672799-0800 chronod [co.appevolve.onewidget.widgetx:widgetx:small:1536744920620481560@148.0/148.0/20.2] reload: could not decode view
error 14:39:07.674984-0800 kernel Sandbox: chronod(2128) deny(1) file-read-metadata /private/var/mobile/Containers/Shared/AppGroup/9B524570-1765-4C24-9E0C-15BC3982F0DC/downloadedFonts/Chewy/Chewy-Regular.ttf
error 14:39:07.675762-0800 kernel Sandbox: chronod(2128) deny(1) file-read-data /private/var/mobile/Containers/Shared/AppGroup/9B524570-1765-4C24-9E0C-15BC3982F0DC/downloadedFonts/Chewy/Chewy-Regular.ttf
error 14:39:07.708914-0800 chronod [u 8D2C83B3-A6CB-432E-A9D4-9BC8F7056B10:m (null)] [&lt;private&gt;(&lt;private&gt;)] Connection to plugin invalidated while in use.
fault 14:39:07.710284-0800 widgetxExtension -[EXSwiftUI_Subsystem beginUsing:withBundle:] unexpectedly called multiple times.
error 14:39:07.803468-0800 chronod Encountered an error reading the view archive for &lt;private&gt;; error: &lt;private&gt;
It seems that it's a permission issue, and the textview can't access the font file it needs when the widget is rendering.
Notes:
1) Font is definitely registered because I can see them in
for fontFamily in UIFont.familyNames {
for fontName in UIFont.fontNames(forFamilyName: fontFamily) {
print(fontName)
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;...
in both the Main App target and the Widget Extension target
2) If I make make the font part of the app bundle and add to 'Fonts provided by application' , the are loaded absolutely fine in the Main App and the Widget on simulator and iPhone 7 real device.
3) I do see this error sometimes in the Widget extension target log, don't know if it's related.
widgetxExtension[1385:254599] [User Defaults] Couldn't read values in CFPrefsPlistSource&lt;0x28375b880&gt; (Domain: group.co.appevolve.onewidget, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
4) I suspected something to do with app groups, so I tried to copy the font into the Widget Extension container and load from there, but had the same result.
Please help! Thank you.
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
iOS
WidgetKit
Typography
SwiftUI
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?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
SwiftUI
WidgetKit
App Intents
I would like to add a Live Activity to my app, but unfortunately I always get an error message. When I go into the Identifiers via the Developer Portal and look at my app, there is no Activity Kit or Live Activity in the Capabilites that I could activate. In XCode I don't see the option for Signing & Capabilities either... Can anyone help me how to add this correctly? Thanks in advance!
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Do we need to include a 1x, 2x, and 3x version of each asset shown on the widget? Can we instead just supply a single 3x version and have the system display this for all device types? We are concerned about our growing app size
I've noticed that the when starting live activities via a remote push-to-start notification, the live activity widget consistently succeeds in displaying on the lock screen. However push-to-update token is not always received by the task observing the pushTokenUpdates async-sequence.
Task {
print("listening for pushTokenUpdates")
for await pushToken in activity.pushTokenUpdates {
let token = pushToken.map {String(format: "%02x", $0)}.joined()
print("Push token: \(token)")
}
}
The log will print "listening for pushTokenUpdates" however occasionally the "Push token: ___" line will not be present even when the widget has displayed on screen. This happens even if the "allow" button has been selected on live activities for that app. The inconsistent behavior leads me to believe there is an issue at the ActivityKit level. Would appreciate any feedback in debugging this!
Confusion
Based on the fact that the subscription is requested on a Activity type, I assumed that the push-to-start tokens would be different. But the push-to-start token for WidgetExtensionAttributes and WidgetExtensionAttributesOther were identical. This is misleading.
The code below prints identical tokens even though the name of the token and their underlying schema are different.
Code Sample
func getTokens() {
Task {
if let data = Activity<func getTokens() {
Task {
if let data = Activity<WidgetExtensionAttributes>.pushToStartToken {
print("exists:", data.hexadecimalString)
} else {
print("requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributes>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("new:", ptsTokenString)
}
}
}
Task {
if let data = Activity<WidgetExtensionAttributesOther>.pushToStartToken {
print("other exists:", data.hexadecimalString)
} else {
print("other requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributesOther>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("other new:", ptsTokenString)
}
}
}
}>.pushToStartToken {
print("exists:", data.hexadecimalString)
} else {
print("requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributes>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("new:", ptsTokenString)
}
}
}
Task {
if let data = Activity<WidgetExtensionAttributesOther>.pushToStartToken {
print("other exists:", data.hexadecimalString)
} else {
print("other requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributesOther>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("other new:", ptsTokenString)
}
}
}
}
Activity Types
struct WidgetExtensionAttributesOther: ActivityAttributes {
public struct ContentState: Codable, Hashable {
var age: Int
}
var addresses: [String]
}
struct WidgetExtensionAttributes: ActivityAttributes {
public struct ContentState: Codable, Hashable {
var emoji: String
}
var name: String
}
Docs
After much investigation I noticed the wording of the docs kind of hint that the push-to-start token is per ActivityKit as it says:
An asynchronous sequence you use to observe changes to the token for starting a Live Activity with an ActivityKit push notification.
But docs and the API don't align well.
Questions
Is it correct that the push-to-start token is per app? If so then is there a reason that that API designers decided to still have to pass a specific type and not just make a request without passing a type?
Should I maybe file a radar?
Is it correct to say push-to-start is per app, while update tokens are per instance. i.e. if I have two soccer matches, then unless the push-to-start token was refreshed by the OS, then both would use the same push-to-start token, however each match would have a unique update token?
In WatchOS 26 you can now configure Apple Watch Widgets that use AppIntents instead of having a preconfigured option via AppIntentRecommendation.
This is demonstrated in the Weather Details Widget. In that, the Intent has been set up such that the options have icons for each parameter.
How can I update my Intent code to offer this?
struct DataPointsWidgetIntent: AppIntent, WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Data Points Widget Configuration"
static var description = IntentDescription("Configure the individual data point display for Widgets.")
static var isDiscoverable: Bool { return false}
init() {}
func perform() async throws -> some IntentResult {
print("DataPointsWidgetIntent perform")
return .result()
}
@Parameter(title: "Show Individual Data Points", default: true)
var showDataPoints: Bool?
@Parameter(title: "Trend Timescale", default: .week)
var timescale: TimescaleTypeAppEnum?
static var parameterSummary: some ParameterSummary {
Summary("Test Info") {
\.$showDataPoints
\.$timescale
}
}
}
enum TimescaleTypeAppEnum: String, AppEnum {
case week
case fortnight
static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Trend Timescale")
static var caseDisplayRepresentations: [Self: DisplayRepresentation] = [
.week: "Past Week",
.fortnight: "Past Fortnight"
]
}
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
WidgetKit
Intents
WeatherKit
App Intents