Is it possible to display a widget based on the backend response/UserDefaults flag?

Viewed 96

I am trying to implement A/B tests for my widgets and I tried to do it based on the supportedFamilies modifier - if someone suppose to not see it, just return an empty array - but it seems like the code there is not always called when the user is modifying the screen, at least this is my observation. I am wondering...is there another way to achieve my goal? Does anyone have any experience?

var supportedFamilies: [WidgetFamily] {
    let variant = experimentProvider.getVariant()
    return variant.isOn ? [.systemSmall, .systemMedium] : []
}

var body: some WidgetConfiguration {
    IntentConfiguration(kind: kind, intent: Intent.self, provider: Provider()) { entry in
            //...
    }
    .configurationDisplayName("Placeholder")
    .description("Placeholder")
    .supportedFamilies(supportedFamilies)
}
0 Answers
Related