简体   繁体   中英

Ways of Safari App Extension to communicate with containing app

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM