Ways of Safari App Extension to communicate with containing app

1k Views Asked by At

I have a Safari App Extension that injects a button over images into a specific website and when tapping that button I want to trigger a function with some parameters in the application that contains the safari app extension (NOT from .js to extension handler)

How can I communicate from the Safari App Extension with the main app in real time? NSUserDefaults trough app groups does not seems a good idea

1

There are 1 best solutions below

0
On

If you don't (can't) listen to updates of "shared user defaults" (using a group SuiteName). Then you may try with Distributed Notifications: https://developer.apple.com/documentation/foundation/distributednotificationcenter

It's quite simple and similar to messaging between Content Scripts and Safari App Extension.