Use for WidgetKit introduced in iOS 14 and macOS Catalyst 14
Questions tagged [widgetkit]
520 questions
0
votes
1 answer
Open UIViewController from iOS14 WidgetKit
I have a very simple app flow. ParentVC and ChildVC. In the ParentVC, I have a collection view and on its didSelectItem, the ChildVC opens up with the relative content. Now I have used iOS 14 WidgetKit to create Small & Medium size widgets which…
0
votes
0 answers
How to make data available across folders when creating iOS app widget?
I wanted to create widget for my app. I have used api to display data in my app. But I don't understand how to display the same data in widget. The classes/structs are not in scope. How to get around it?

Muskan Arora
- 56
- 11
0
votes
1 answer
How to get the systems Battery Percentage in Swift 5?
I'm trying to include a battery feature to my widget, but I can't seem to get the mobile's battery percentage...
I tried:
import UIKit
struct BatteryControl {
static func getBatteryPercent() -> Int {
…

Sarvesh Sridhar
- 387
- 3
- 3
0
votes
1 answer
How to add map to a iOS 14 widget?
I add Map to iOS Widget but it doesn't work.
VStack(alignment: .leading, spacing: nil, content: {
Text("Placeholder")
Map(coordinateRegion: $reg, showsUserLocation: true, userTrackingMode:$trackmode)
Spacer()
})

cadaverousblue
- 133
- 3
0
votes
1 answer
WidgetKit won't share data between iOS and widget
to make it short, my iOS app download some data from a server and put it into an array.
I wanna share the array count with the widget using the AppGroups.
I save the array count number to UserDefaults like this:
if let userDefaults =…

I Don't Tell
- 264
- 1
- 15
0
votes
1 answer
iOS 14 Widget not displaying NSLocationWhenInUseUsageDescription when asking location permission
I am using CoreLocation in my iOS 14 Widget to track the user's location. It works perfectly. As per documentation, I have added the NSLocationWhenInUseUsageDescriptionto the Widget's Info.plist file.
The system correctly asks for permission to…

hotdogsoup.nl
- 1,078
- 1
- 9
- 22
0
votes
1 answer
SwiftUI Widgets with Siri Intent for dynamic list of options
With iOS 14 and the new widgets you can either have a StaticConfiguration or an IntentConfiguration where you define a custom intent. I have created a simple Intent in the intent configuration file called "MySimpleIntent". Code is generated by…

Janosch Hübner
- 1,584
- 25
- 44
0
votes
1 answer
Detect when Text.DateStyle.timer reaches 00:00
So I am new to WidgetKit and SwiftUI, but is there an event or a way to detect when the countdown reaches 00:00 for Text()?
let components = DateComponents(minute: 15)
let futureDate = Calendar.current.date(byAdding: components, to:…

Sayed
- 1,022
- 3
- 12
- 27
0
votes
1 answer
SwiftUI WidgetKit: How to open specific viewController when app is terminated
I am building widgets for iOS 14 using WidgetKit and would like to open specific viewControllers of my app when users tap on different Links on the widget. The opening of the app works only when my app is in the background. When the app is…

Koh
- 2,687
- 1
- 22
- 62
0
votes
2 answers
How to pass uiviewcontroller data to swiftui widget class
How to pass uiviewcontroller data to swiftui widget class i am unable to do it with app groups also write now i am sending it with userdefaults but unable to do it
if let userDefaults = UserDefaults(suiteName: "group.com.soup.ios.app") {
…

Faraz Ahmed
- 79
- 10
0
votes
1 answer
Send a struct array to widget on iOS 14
I have a struct array, for example:
struct Note {
let id: Int
let text: String
let timestamp: Int64
}
I want to send to the widget. As I searched, I can send an array through AppGroup with userDefaults, I need some tricks to send…

Robert kont
- 165
- 1
- 8
0
votes
1 answer
Xcode Widget Extension with React-Native how to set @main properly
I added a WidgetExtension via Xcode to my react-native project, however I can't get them to work simultaneously. This is because both main.m and my widget are 'main'. Xcode says error: 1 duplicate symbol for architecture arm64
To fix this I removed…

Kipnoedels
- 1,118
- 7
- 22
0
votes
1 answer
Reload All Timeline of Widgetcenter
I use WidgetCenter.shared.reloadAllTimelines() in my main app to refresh my widget.
The widget contains a picture and a String which gets fetched with a json request.
If I use the code above the picture gets refreshed immediately. So thats how it…

submariner
- 308
- 1
- 5
- 23
0
votes
1 answer
How to display data from Core Data in WidgetKit
Here is my code and I tried to list stored data from Core Data in WidgetKit its not showing at all. I already created app group and the data are showing at preview but when we add widget to home screen nothing shows up. I'm not sure the way I did is…

Timothy
- 1
0
votes
0 answers
Getting data from UIKit to WidgetKit in Swift
I was trying to make a widget for the app, but struggling to get the right data to the widget.
App is written in Swift 5.
I need to get data with the progress of the user
Depending on the user progress (if there is some progress show some content…

Jkrist
- 748
- 1
- 6
- 24