WidgetKit configuration display name?

I having a question about widget's configuration: configurationDisplayName and description. Can I change this value by an action from main app, and if I can, how can I do that? For example I tap a button and widget's name change.

Code Block
  var body: some WidgetConfiguration {
    return StaticConfiguration(kind: kind, provider: Provider()) { entry in
      WidgetView()
    }
    .configurationDisplayName("My Widget")
    .description("This is my widget")
  }

Thank you.
Same here. I'm having this problem too. Notice me when you have the answer. Thanks.
I have an idea... I honestly don't know if it will work but! You can create App Group between your iOS app and Extension, then using UserDefaults for groups you can "share" the display name and description.

What do you think? Might work?
I leave you an example of how I use it in my app. With this you can have different titles and descriptions for each widget.



struct MyPempisSmallRegularPaymentWidget: Widget {

    let kind: String = "MyPempisSmallRegularPaymentWidget"    

    var body: some WidgetConfiguration {

        StaticConfiguration(kind: kind, provider: Provider()) { entry in

            MyPempisRegularPaymentsWidgetEntryView(entry: entry)

        }

        .configurationDisplayName("Regular Payments")

        .description("Quick glance at your Regular Payment Global Amount")

        .supportedFamilies([.systemSmall])

    }

}

struct MyPempisMediumWidget: Widget {

    let kind: String = "MyPempisMediumWidget"

    var body: some WidgetConfiguration {

        StaticConfiguration(kind: kind, provider: Provider()) { entry in

            MyPempisWidgetEntryView
Medium(entry: entry)

        }

        .configurationDisplayName("Compact Overview")

        .description("Quick glance at your Global Amount, Your Last Transaction Added & The Global Amount of your Regular Payments")

        .supportedFamilies([.systemMedium])

    }

}



@main

struct MyPempisWidgets: WidgetBundle {

    @WidgetBundleBuilder

    var body: some Widget {

        MyPempisSmallWidget()

        MyPempisSmallRegularPaymentWidget()

        MyPempisMediumWidget()

    }

}



More info -> https://developer.apple.com/documentation/swiftui/widgetbundle


I have an idea... I honestly don't know if it will work but! You can create App Group between your iOS app and Extension, then using UserDefaults for groups you can "share" the display name and description.

I would give this a try. In my configuration I am also using UserDefaults to get certain data from the main app.
You could say:
Code Block
var body : some View{
Button(action: {buttonPress(title: "newTitle")}){
Text("change widget title")
}
}
func buttonPress(title: String){
UserDefaults(suiteName: "yourAppGroup")?.setValue(title ,forKey: "widgetTitle")
print("title updated")
}

and in your widget extension you just get the "widgetTitle" value from User Defaults.



The problem here is that configurationDisplayName is provided by modifier, not by a property. Since it's a declarative style.

WidgetKit configuration display name?
 
 
Q