iOS 17 StandBy Mode Opt Out for Widgets?

My app's Widgets on iPhone rely on access to the Health Store to update. This makes them appearing in the new StandBy mode not a good experience as they never update.

Is there a way to opt out of this mode but keep the options for my users to put Widgets on their home screen?

Thanks

Accepted Reply

The thing you want to do is possible using disfavoredLocations(for:).

https://developer.apple.com/documentation/swiftui/widgetconfiguration/disfavoredlocations(_:for:)

  • Perfect, Thank You!

    For those interested, I created this modifier to work across all my small and medium widgets on iOS:

    extension WidgetConfiguration { func widgetOnlyOnHomescreen() -> some WidgetConfiguration { if #available(iOSApplicationExtension 17.0, *) { return self.disfavoredLocations([.standBy, .iPhoneWidgetsOnMac, .lockScreen], for: [.systemSmall, .systemMedium]) } else { return self} } }

Add a Comment

Replies

I also want to ask this question. In addition, I want to opt out of the systemSmall lock screen widget on the iPad. It seems that as long as it is compiled through the iOS 17 SDK, the widget must adapt to all positions.

The thing you want to do is possible using disfavoredLocations(for:).

https://developer.apple.com/documentation/swiftui/widgetconfiguration/disfavoredlocations(_:for:)

  • Perfect, Thank You!

    For those interested, I created this modifier to work across all my small and medium widgets on iOS:

    extension WidgetConfiguration { func widgetOnlyOnHomescreen() -> some WidgetConfiguration { if #available(iOSApplicationExtension 17.0, *) { return self.disfavoredLocations([.standBy, .iPhoneWidgetsOnMac, .lockScreen], for: [.systemSmall, .systemMedium]) } else { return self} } }

Add a Comment