Post

Replies

Boosts

Views

Activity

Reply to [iOS 18] Colors from asset catalog render as pure white on tinted widgets
When you select tinted your widget is rendered in accented mode. Accented mode splits the UI elements into two groups, the default group and the accented group. Basically you only get two colors the accented group will get the tinted color the other group is white. You swap your UI elements between the groups using the widgetAccentable modifier: https://developer.apple.com/documentation/swiftui/view/widgetaccentable(_:) You can still apply an opacity to the UI elements if you want. If you want them to be the original color then you can use the https://developer.apple.com/documentation/widgetkit/widgetaccentedrenderingmode property but that only applies to Image elements.
Sep ’24
Reply to Widgets not working in iOS 17.2
We were also having this issue. It was recommended to make sure that any images you have aren't too big, ideally somewhere around the size of the widget dimensions, that should help fix this problem. Reducing the size of the images we were using as backgrounds to our widgets seems to have helped us.
Jan ’24
Reply to WeatherKit REST API access
The WeatherKit option is un the Capabilities tab not App Services. You also need to register a WeatherKit key in the top level Keys section in the developer site. Once you have completed both of those step, this question has information on how to call the REST API using a JWT: https://developer.apple.com/forums/thread/707418
Jun ’22
Reply to Can't test subscription upgrade/downgrade. iOS doesn't use the sandbox account
Unfortunately, entering my real apple ID/password does not work. It show success but the upgrade/downgrade never occurs the UI still shows the original subscription level. Signing out of the production AppleID and only having the sandbox tester on the device doesn't work either. In that scenario the password box is displayed but with an empty username in the dialog, entering the sandbox password just fails. I'm confused how people are successfully testing these scenarios :/
Mar ’21
Reply to Widget getSnapshot method won't call for second time
There is no guarantee that getSnapshot will be called each time the galley is opened, the OS might cache previous results as you've seen. In the case the user has never logged in to the app and adds the widget, so their is no previous cached data in your getSnapshot call you could check the auth status of your app and if the user is logged out: Show a "Logged out" UI in the widget Show some canned data to fill out your widget with example data (to make it look good in the gallery). Then once the user logs in via the app you can get the widget to refresh its UI by calling: https://developer.apple.com/documentation/widgetkit/widgetcenter/reloadalltimelines() For the other case where you don't want cached data in the gallery once the user logs out, you could try calling reloadAllTimelines() when the user logs out in the app and see if that causes the snapshot to be updated.
Sep ’20
Reply to Removing a widget from project
If you set the supportedFamilies modifier on the WidgetConfiguration to [] then the widget no longer shows in the widget gallery. That might be an option. e.g. public var body: some WidgetConfiguration {     StaticConfiguration(       kind: kind,       provider: Provider()     ) { entry in       widget_mainEntryView(entry: entry)     }     .configurationDisplayName("Foo")     .description("Foo")     .supportedFamilies([])   }
Aug ’20
Reply to can I get current location in widgetKit
You need to make sure you have both these plist values set in your widgets Info.plist file: <key>NSWidgetWantsLocation</key> <true/> <key>NSLocationUsageDescription</key> <string>Put some text here</string> Then when you open the widget gallery, looks like from beta5 onwards iOS will show a prompt asking you to allow/deny location permissions to the widget. The next important thing is that inside getTimeline() if you are creating an instance of CLLocationManager you must keep a reference to it past the end of the getTimeline call otherwise no updates will happen on the delegate. In my case I just created a wrapper class that the widget stores as a property then I setup the CLLocationManager instance on the first run of getTimeline and assign it to a field in the wrapper class. At least this worked for me :)
Aug ’20
Reply to How to "force" WidgetKit TimelineProvider to render placeholders?
I'm not sure if this would work for your case but you could just add a field like "applyRedaction" to your entry object, set that to true in the case where your widget doesn't have permission, fill in the rest of the field with static data like you do in getSnapshot() and return the entry from getTimeline using the completion method as in the success case. Then in your widget main entry struct where the view is returned you can just manually apply the redaction based on the value of the applyRedaction value e.g. if entry.applyRedaction { &#9;return AnyView(Text("Hello").redacted(reason: .placeholder)) } else { &#9;return AnyView(Text("Hello")) } I use this pattern in my widget to just show a redacted view of my widget in the case that there are any transient network errors.
Aug ’20