Embed Widget in Network Extension

I have a VPN app that has an embedded Network Extension. I wish to create a Widget based on the Network Extensions status. i.e Connect and what server/Country.

If I take the traditional route of embedding the widget in the main app and call WidgetCenter.shared.reloadTimelines in the extension it works as expected, but ONLY if the parent app is still alive. The minute the parent app goes away calling WidgetCenter.shared.reloadTimelines does nothing.

I have tried embedding the plugin inside of the Network Extension plugin but this as expected does not work.

Is this a limitation of WidgetKit ( No ability to be updated from a running plugin)? Or is there a better way to update this widget


Post not yet marked as solved Up vote post of mikeKane Down vote post of mikeKane
1.6k views

Replies

I’m not surprised that this isn’t working; this is likely an edge case that no one considered. Indeed, we saw similar problems with Today extensions back in the day (r. 25869716).

Unless someone else chimes in, my advice would be that you file a bug about this. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thanks for your reply

Here is the ticket number - FB9002170

We're in the exact same boat now: we have a VPN app and would like to write a widget which is able to show the connection status. Is there a way to trigger a widget update from a Network Extension now? Or would a widget be able to subscribe to notifications like NEVPNStatusDidChange ?

I just tried calling WidgetCenter.shared.reloadAllTimelines() from our Network Extension on iOS 15.7 and iOS 16, and it works as expected on both. So as long as the NE is stopped gracefully (as opposed to crashes or getting killed by the system), we're now able to tell our widgets that a connection is running or has stopped, and reload the the widgets.

  • Interesting, for me WidgetCenter.shared.reloadAllTimelines() worked from Network Extension only during debugging sessions. When I tried to test it without debugger, it did not work. I tested with iOS 15.4.1 though. Could it be that the bug was fixed in a later iOS versions?

Add a Comment