This documentation guide and the corresponding demo project show how the the Web Extension Handler can inherit from NSExtensionRequesetHandling
and implement beginRequest
to receive and reply to messages sent from the background script via browser.runtime.sendMessage()
.
The guide also mentions how browser.runtime.connectNative
and SFSafariApplication.dispatchMessage
can be used to send messages from the Handler to the background script, but the code is not in the example project.
Further, it seems that SFSafariApplication
is not available on iOS.
How can I send a message originating from the Extension Handler to notify the background script of events coming from native code (e.g. UserDefaults changes)? Is polling from the background script the only option?