How to add Buttons to a iOS 14 Widget

Viewed 8107

I'm trying to add buttons to a widget having family type ".systemLarge". I want to execute some code without opening the app.

Anyone knows how to do that?

For example the Shortcuts App Widget includes buttons you can tap to execute a shortcut without opening the app.

2 Answers

You can add Link controls on medium and large size widgets to get a button like behavior.

This won't allow you to create interactive widgets, which change their content by clicking elements inside the widgets. But you will be able to tell which "link" was clicked based on the widgetUrl provided when your app gets activated through the widget.

See the chapter Respond to User Interactions here: https://developer.apple.com/documentation/widgetkit/creating-a-widget-extension

Related