We would need to keep a Safari App Extension alive for some time. Is there some API for that, or does anyone have experience with it?
The rationale is that when the user is working with our container application, we need the extension to reflect some changes and do appropriate processing at its side (like, change the toolbar icon, change some icons injected to the HTML page, etc). We have a communication channel through which the container application could let the extension know what to do, but of course, so that this works, the extension must be running.
Alas we can't simply use +[SFSafariApplication dispatchMessageWithName:toExtensionWithIdentifier:userInfo:completionHandler:], for it would activate Safari; but we need our application to stay active whilst this happens.
For the moment the only work-around we found is to send a message from an injected script to the extension code often enough, so that Safari (or launchd or whomever controls this) would not kill the extension. That would probably work (would need thorough testing), but is pretty darn ugly, not speaking of the question which frequency is “often enough”.
Can anyone see a better solution? Thanks!