0

How can we add a widget snapshot in "Add Widget" list as I have marked in red below?

Once I create a widget I can see my app available under the list however not able to make it appear as a snapshot or image. Any help will be appreciated.

struct ToDoLockScreenWidget: Widget {
let kind: String = "Lock Screen Widget"
var body: some WidgetConfiguration {
    if #available(iOSApplicationExtension 16.0, *) {
        return StaticConfiguration(kind: kind, provider: Provider()) { entry in
            ToDoLockScreenWidgetView(entry: entry)
                .widgetURL(URL(string: WidgetURL.lockScreenWidget))
        }
        .supportedFamilies([.accessoryCircular])
        
    } else {
        // Fallback on earlier versions
        return EmptyWidgetConfiguration()
    }

}

thank you. enter image description here

6
  • Have you implemented the TimelineProvider? Lock Screen widgets are not any different than Home Screen widgets in this regard. Also, you don't need a fall back in your if #available. You can't use a Lock Screen widget pre-iOS 16 Commented Oct 1, 2022 at 19:01
  • Yes, you are right.. there is not much change while adding widgets either to lock screen or home screen.. however, showing snapshot directly to "Widget Gallery" I think there would be something more we need to do..which I am not able to figure out Commented Oct 3, 2022 at 6:47
  • That is the same as well. Just set up your timeline provider as for any other widget, so you need func getSnapshot(in context: completion:), getTimeline(in context: completion:), func previewEntry() -> Entry and that you have the loc screen widgets as supported. Remember, if you do not have a minimum OS version of 16, you need to use if #available to add the support. As long as your widget works, the system will show you widget with current data, if available, otherwise with the preview data. Commented Oct 3, 2022 at 17:54
  • @Yrb I am able to get the lock screen widget, there is no problem. note that I can see it as part of the widget list..However, as shown in the above image I want to see it as a snapshot/preview in the "Widget Gallery".. Commented Oct 4, 2022 at 12:51
  • 1
    Do you mean at the top of the "Add Widgets" screen? That is Apple that determines that. I suspect based on how often the App is used. Otherwise, you have to scroll to see the app and then choose the Lock Screen widget there. Commented Oct 4, 2022 at 17:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.