Member-only story
Limitations of Migrating your iOS Today Extension to WidgetKit
iOS 14 has some great new features, including new Widgets that can be placed on the home screen.
For some of my clients apps we’re using Today Extensions extensively. It also implements some advanced concepts like using MMWormHole for communicating with the underlying application, to perform actions in the background without moving the app to the foreground.
While I was migrating a Today Extension widget over to Apple’s new WidgetKit, I quickly stumbled upon its biggest limitation.
While WidgetKit widgets in iOS 14.0 can perform logic independantly from the app (like download data from a webservice), they can’t have true interactions, like buttons. Basically, they are just simple interfaces presenting dynamic data without any user interaction within the widget.
Apple’s Shortcuts widget is an exception, it actually does contain buttons. This is an exception, Apple doesn’t let third parties implement this in widgets.
There is still a way (or let’s say: workaround) to let a user interact with the app through WidgetKit widgets. The method is described in a StackOverflow answer here. In short: this workaround provides a way to know on what view a user has tapped inside the widget. But all of this can only be done when opening the app itself…