Bring widgets to new places

RSS for tag

Discuss the WWDC23 Session Bring widgets to new places

View Session

Posts under wwdc2023-10027 tag

9 Posts
Sort by:
Post marked as solved
4 Replies
1.1k Views
When applied .contentMarginsDisabled() modifier to WidgetConfiguration, Widget extension crashes on launch in Xcode 15 Beta 3. struct TestWidget: Widget { let kind: String = "TestWidget" var body: some WidgetConfiguration { return IntentConfiguration(kind: kind, intent: TestIntent.self, provider: TestProvider()) { entry in TestView(entry: entry) } .configurationDisplayName("TestWidget") .description("This is TestWidget.") .supportedFamilies([.systemMedium]) .contentMarginsDisabled() // << Here } } Though it works in Xcode 15 Beta 2. Anyone facing same issue ?
Posted Last updated
.
Post marked as solved
8 Replies
1.6k Views
To bring my widgets to iPad lock screen, i need to detect my widget that has a background to display different contents, watch the wwdc 23 video it tells we can use .showsWidgetContainerBackground environment to apply that goal, but the problem is this code wouldn't compile because .showsWidgetContainerBackground only available in iOS 17 @available(iOS 14.0, *) struct MyWidgetView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground var body: some View { ... } } So, my solution is use a environment wrapper, like this: @available(iOS 17.0, *) struct EnvironmentWrapper: View { @Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground var body: some View { VStack(alignment: .leading) { Text("Wrapper Has Background: \(showsWidgetContainerBackground ? "YES" : "NO")") } } } extension View { var showsWidgetContainerBackground: Bool { if #available(iOS 17.0, *) { return EnvironmentWrapper().showsWidgetContainerBackground } else { return true } } } But it didn't work, this is the example: @available(iOS 17.0, *) struct EnvironmentWrapper: View { @Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground var body: some View { VStack(alignment: .leading) { Text("Wrapper has background: \(showsWidgetContainerBackground ? "YES" : "NO")") } } } @available(iOS 17.0, *) struct ExampleView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground var body: some View { VStack(alignment: .leading) { Text("Read from self: \(showsBackground ? "YES" : "NO")") EnvironmentWrapper() Text("Read from wrapper: \(EnvironmentWrapper().showsWidgetContainerBackground ? "YES" : "NO")") } .font(.system(size: 12, weight: .medium)) } } As you can see, if i read it directly from self, it works, but if i read from outside, it always return true i also try to load a view first in the wrapper, but it didn't work either func getShowsBackground() -> Bool { let _ = body return showsWidgetContainerBackground }
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.4k Views
I have an accessoryCircular Lock Screen widget built for iOS 16: ZStack { AccessoryWidgetBackground() VStack { Text("MON") .font(.caption) Text("6") .font(.title) } } When run on iOS 17 it renders an error “Please adopt containerBackground API”. So I changed it to: VStack { Text("MON") .font(.caption) Text("6") .font(.title) } .containerBackground(for: .widget) { AccessoryWidgetBackground() } This causes the error to go away but the circular background is no longer visible (tested with iPadOS 17b2). What’s the right way to implement this?
Posted
by Jordan.
Last updated
.
Post not yet marked as solved
1 Replies
572 Views
hi, all I'm in the process of adapting a new feature to my live activity, which allows users to interact directly with the live activity using button(intent), without having to jump to the app. I've implemented an intent using LiveActivityIntent, the intent code is included in the main app and widget target, and all the functionality and logic works perfectly in the debug mode. After I submitted it to testflight in release mode and installed it on the real machine, I tested the above functionality and found that it doesn't work. I checked the logs of the phone and found that there is a similar error in the console Could not find an intent with identifier xxxxxIntent, mangledTypeName: Optional("xxxxxV"), the TypeName in the last part of the log has one more "V" than my real code, and I made sure that there is no such V in the code.
Posted
by blacksun.
Last updated
.
Post not yet marked as solved
0 Replies
758 Views
ios 17 interactive widget api call in background An API request is being made through Interactive widget in iOS 17.0 version. The desired situation is to request an API through the widget's Intent and receive a response from the server. (Because it is opened from Intent, the app does not open.) But a problem occurred here. When both the main app and the widget are built, the above request works well. However, even if the build is stopped, the request is made normally if the app is in the foreground state. However, when the app is in the background, API calls are not made through Intent. How can I solve this? Desired situation: API call request through App Intent under any network condition when the app is turned off (may not be reflected separately in the widget) Problem Situation: API call through Celluar data fails when the app is turned off. What's currently working properly: Successful API call through Wi-Fi when the app is turned off Api call is successful under any network conditions when the app is turned on.
Posted
by SOEY.
Last updated
.
Post marked as solved
1 Replies
542 Views
When using @Environment(.showsWidgetContainerBackground) inside any view, the app and widgets crash in a real device with iOS17 beta 6. The same build works perfectly on simulators and a real device running iOS17 beta 5. Using XCode 15 beta 6 to build the app. I am getting this error: Symbol not found: _$s7SwiftUI17EnvironmentValuesV9WidgetKitE05showsE19ContainerBackgroundSbvg I just created a new blank project and only added that line and it crashes. Filled a feedback report. I am the only one? struct ContentView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground: Bool var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() } }
Posted
by rosday.
Last updated
.
Post marked as solved
3 Replies
1.4k Views
Hi, I'm playing with the new xcode 15 beta and am trying to solve the extra paddings around the widget by adding .contentMarginsDisabled() at the end as instructed by https://developer.apple.com/videos/play/wwdc2023/10027/ IntentConfiguration(...) ... .contentMarginsDisabled() } it works fine for ios17 and actually fixed my extra padding problem, but on ios16 the app is not shown in the search widget menu anymore, anyone ran into the same issue?
Posted
by amjiang.
Last updated
.