App Extension as a long running proxy for Safari Web Extension

I currently have an architecture where I need to forward messages from the Safari Web Extension to another app through the App Extension.

I understand from the docs on Apple, App Extensions are not meant to be used as a long running background task, but if it is just proxying messages, is it advisable to keep pinging the app extension to keep it alive and use it as a long running task in the background for proxying messages ?


Replies

I need to forward messages from the Safari Web Extension to another app through the App Extension

Your topology (or wording) is a little confused. Are you using a Safari Web Extension or Safari App Extension? They are distinct and have very different architecture. I have a feeling you're referring to a Safari App Extension's SafariExtensionHandler as the "App Extension" and the popover as the "Web Extension". If not, please clarify this.

I understand from the docs on Apple, App Extensions are not meant to be used as a long running background task

Where does it state this? A Safari App Extension supplies a process that runs in the background. If you open Terminal.app and run

ps aux | grep "[ ]Extension"

you'll see a list of all the extensions you have running. Ergo an App Extension is capable of receiving messages from the scripts it injects for the entire lifetime of the process. There's no need to "ping" it to "keep it alive".

  • Thanks @bermudalocket. Is it possible to send asynchronous messages from the app extension to the scripts running in the browser?

Add a Comment