macOS Widget query data from local app

I would like to create a Widget for macOS that queries for data stored and managed by an installed macOS native app.

Is it possible to use a URLSession to query and return locally stored data from an installed macOS application instead of doing a network request ?

This would use the deep link URL associated and registered with the local app.

Any security issues to be aware of?

Thanks
Is the macOS app in the same team as the one that your widget is in? If so, you should use a shared group container to share the data. You can get some details on how to do this here: https://developer.apple.com/documentation/foundation/nsfilemanager/1412643-containerurlforsecurityapplicati and some older (but still relevant) info here: https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html

While widgets can use URLSession to do network requests, it sounds like that may be overkill for your situation.
Yes both the Widget and the macOS app would be in the same team.

However that app data to be surfaced within the widget is not contained in a file but in a SQLite database.

So I understand correctly, I would have to create an AppExtension of type Action that would perform the proper data retrieval request on the shared database file.

Then the widget could leverage that App Extension to extract retrieved data and have those displayed in the Widget UI.

Let me know if solution path makes sense. Thanks for your reply.
macOS Widget query data from local app
 
 
Q