WidgetKit

RSS for tag

Show relevant, glanceable content from your app on iOS and iPadOS Home Screen and Lock Screen, macOS Desktop, Apple Watch Smart Stack and Complications, and in StandBy mode on iPhone.

Posts under WidgetKit tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

WidgetKit Refresh Policy: onOverrideList == 1
I have an iOS app with widgetkit extension, and the widgets stopped updating. I attached the console, and saw these lines for widgets of my app: com.apple.widget.myApp::myWidgetKind::-6207022974507159915:417E34:[ {name: Widget Refresh Policy, policyWeight: 0.010, response: {Decision: Must Not Proceed, Score: 0.00, Rationale: [{onOverrideList == 1 AND IndividualBalance == -1}]}} ], FinalDecision: Must Not Proceed} The IndividualBalance == -1 apparently means that the app was updating widgets too often, but what about onOverrideList == 1? There seems to be no info online about this flag, and LLMs seem to suggest that the app got onto some kind of Apple's blacklist for updating too often, is that right?
0
0
297
Mar ’24
How long can widget be executed after being activated by the iOS system
Widgets are activated by the iOS system at regular intervals, and the task code defined in the TimelineProvider is executed. How long can this task code be executed at most? I don't think the system will allow tasks defined in the timeline to be executed continuously (looking like a background resident program), so there must be a time limit. If you know, or if there are related document links, please let me know Thank you.
0
0
158
Mar ’24
Single Radio Station Lock Screen Audio Card
I am working on a radio app. This is the first time and I have a problem with lock Screen Audio Card. According to docs It looks ok but could you please check why I can not display Audio Now Playing Card on lock Screen. 2 Code samples, 1. Now Playing and 2. Logic of current song and Album art. 1. Now Playing // Create a dictionary to hold the now playing information var nowPlayingInfo: [String: Any] = [:] // Set the title of the current song nowPlayingInfo[MPMediaItemPropertyTitle] = currentSong // If album art URL is available, fetch the image asynchronously if let albumArtUrl = albumArtUrl { URLSession.shared.dataTask(with: albumArtUrl) { data, _, error in if let data = data, let image = UIImage(data: data) { // Create artwork object let artwork = MPMediaItemArtwork(boundsSize: image.size) { _ in image } // Update now playing info with artwork on the main queue DispatchQueue.main.async { nowPlayingInfo[MPMediaItemPropertyArtwork] = artwork MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo } } else { // If there's an error fetching the album art, set now playing info without artwork MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo print("Error retrieving album art data:", error?.localizedDescription ?? "Unknown error") } }.resume() } else { // If album art URL is not available, set now playing info without artwork MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo } } 2. Current Song, Album Art Logic let parts = currentSong.split(separator: "-", maxSplits: 1, omittingEmptySubsequences: true).map { $0.trimmingCharacters(in: .whitespaces) } let titleWithExtra = parts.count > 1 ? parts[1] : "" let title = titleWithExtra.components(separatedBy: " (").first ?? titleWithExtra return title } func updateSongInfo() { let url = URL(string: "https://live.heartfm.com.tr/listen/heart_fm/currentsong")! URLSession.shared.dataTask(with: url) { data, response, error in if let data = data, let songString = String(data: data, encoding: .utf8) { DispatchQueue.main.async { self.currentSong = songString.trimmingCharacters(in: .whitespacesAndNewlines) self.updateAlbumArtUrl(song: self.currentSong) } } }.resume() } private func updateAlbumArtUrl(song: String) { let parts = song.split(separator: "-", maxSplits: 1, omittingEmptySubsequences: true).map { $0.trimmingCharacters(in: .whitespaces) } let artist = parts.first ?? "" let titleWithExtra = parts.count > 1 ? parts[1] : "" let title = titleWithExtra.components(separatedBy: " (").first ?? titleWithExtra let artistAndTitle = artist.isEmpty || title.isEmpty ? song : "\(artist) - \(title)" let encodedArtistAndTitle = artistAndTitle.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? artistAndTitle albumArtUrl = URL(string: "https://www.heartfm.com.tr/ArtCover/\(encodedArtistAndTitle).jpg") }
0
0
370
Feb ’24
Widgets and App extensions
Hi, I have few questions regarding the widgets. I would like to know whether widget and app extensions are same ? This link(https://developer.apple.com/app-extensions/) says widget is type of app extension but I am not quite sure as few link in web says they are different. so need to confirm here :) Can a widget share same bundle id as the main app ? so basically can we use the same provisioning profile as the main app? If we use the same bundle id and provisioning profile, will there be any issue during the app store submission process.?
0
0
336
Feb ’24
WidgetConfigurationIntent @Parameter sometimes cannot get a value
There is a code: func getData() async -> [Data] { do { let token = try ServiceData.getTokenThrows() let listData = try await ServiceData.fetchDataNew(token: token) // always return list data return listData } catch { return [] } } func entities(for identifiers: [DataModel.ID]) async throws -> [DataModel] { return await getData().filter { identifiers.contains($0.id) } } func suggestedEntities() async throws -> [DataModel] { return await getData() } func defaultResult() async -> DataModel? { return await getData().first } } Sometimes during assembly, when changing user data, the data in WidgetConfiguration Intent @Parameter is not received, although they are in the console, and EntityQuery methods do not throw exceptions. Does anyone have any ideas?
1
0
197
Feb ’24
How to reduce complication extension executable size?
Hello! I'm working on the watchOS app that provides user with multiple fancy complication sets. There are about 50 widgets in our WidgetBundle now. With this amount we reached memory limit and the app crashes: Thread 1: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=15 MB) I inspected complicationExtension.appex content and find out that most volume is occupied by the executable: Localized strings (12 langs) altogether - 165 KB Assets.car - 1.1 MB Imported fonts TTF files altogether - 866 KB complicationsExtension executable file - 8.2 MB Why it takes so much space and how can it be made smaller?
8
0
1k
Feb ’24
Migrating WidgetKit extensions from dual-target to single-target watch app
Is there a way to migrate WidgetKit extensions made using dual-target watchOS apps to single-target apps? When you create a widget extension with a dual-target app, the bundle identifier includes the extra extension domain (com.company.app.watchkitapp.watchkitextension.widgets). When Xcode 15 migrates a dual-target to single-target, it removes “.watchkitextension” from both the watchOS app bundle identifier and the widget extension bundle identifier. watchOS seems to handle migrating the main app just fine, but any complications created with the dual-target do not get migrated and are just blank until the user re-configures, which would be a huge bummer to have to ship. If I try to manually set the bundle identifier back to include “.watchkitextension”, the OS rejects the installation because of the extraneous dot after the parent app’s prefix.
0
0
392
Feb ’24
How to handle a `AppIntent.perform()` error in Widget?
Hello. My project includes a widget target that provides interactive widget functionalities. The document "Adding Interactivity to Widgets and Live Activities" says the following: Additionally, note that the perform() function is marked as throws. Be sure to handle errors instead of rethrowing them, and update your app, widget, and Live Activity as needed. For example, update a widget’s interface to indicate that it displays outdated information if it cannot load new data. https://developer.apple.com/documentation/widgetkit/adding-interactivity-to-widgets-and-live-activities#Implement-the-perform-function, column 3 However, I couldn't find a way how to handle an error in an interactive widget. The Button(intent:) and Toggle(intent:) initializers don't have mechanisms for error handling. Does anyone know a solution for handling errors in interactive widgets?
0
0
304
Feb ’24
Unable to reload widget timeline from App Intent on physical devices
In my app, there's a widget that should change to one color when clicked and then to another color after 10 seconds. When I click the widget button (linked to the App Intent), the widget should refresh. When I debug, this happens as expected. However, if I call WidgetCenter.shared.reloadAllTimelines() in the perform() method of AppIntent, the widget timeline doesn't refresh right away. This issue only happens on real devices and isn't always consistent. In the simulator, the widget refreshes as expected.
1
0
438
Feb ’24
[Widgets] [Gallery] Add system URL Scheme to widget gallery
WidgetKit library was presented appeared on WWDC20, and since then there has been no way to bring users to the Widget Gallery, and this becomes a stumbling block for many developers, since we are not able to send our users to developed widgets I suggest Apple add a custom URL scheme similar to that for system applications: facetime://user@example.com sms:1-111-111-0037 And this URL Scheme is up to Apple, but there is a few thoughts about it: How the URL might look like: widgetgallery: widgetgallery:type=<...>&family=<...> URL Scheme parameters: type - widget's kind string identifier, defined in app family - family of widget This will help make widgets more common among users, as well as increase conversion in their additions. For this reason, the development of widgets will become an appropriate feature for companies
0
0
392
Feb ’24
WidgetKit and VisionOS
Hello all, Is there any best practice how it's possible to add native visionOS support for existing app, that already includes WidgetKit extension, where both targets should share some files? "Your target is built for visionOS but contains embedded content built for the iOS platform (WidgetsExtension.appex), which is not allowed" Thanks a lot!
1
0
326
Feb ’24
Spotify Widget stuck on my screen
I added a spotify widget on the first page of my home screen. That widget is working fine and totally normal. On the second page of my home screen, there is another widget floating with the little minus sign like when you add or delete an app/widget on your screen. My apps sit on top of it, I can't move it, I can't delete it. Anyone dealt with this before?
1
0
252
Feb ’24
iOS 16.0 beta 7 broke Text(Date(), style: .timer) in SwiftUI widgets
Hi, In my apps, the recent iOS 16.0 beta 7 (20A5356a) broke the .timer DateStyle property of the Text view, in a SwiftUI widget. In previous OS and beta, Text(Date(), style: .timer) was correctly displaying an increasing counter. In iOS 6.0 beta 7, Text(Date(), style: .timer) does not update anymore, (and is offset to the left). The other DateStyle (like .offset, .relative, ...) seems to update correctly. Anyone noticed that (very specific) problem ?
38
14
8.4k
Feb ’24