admin管理员组

文章数量:1404624

I have an iOS application that contains Safari Web Extension that uses Declarative Network Request for content filtering. I'd like to have a toggle in the iOS app that disables or enables the whole Web Extension. How can i do it?

Originally I was going to send a message from containing iOS app to the background script to enable/disable according rulesets. But the messaging API to the background script from the app is available on macOS only, not on iOS:

You can’t send messages from a containing iOS app to your web extension’s JavaScript scripts.

I wonder how can I change the settings and let background script know it needs to apply them.

I have an iOS application that contains Safari Web Extension that uses Declarative Network Request for content filtering. I'd like to have a toggle in the iOS app that disables or enables the whole Web Extension. How can i do it?

Originally I was going to send a message from containing iOS app to the background script to enable/disable according rulesets. But the messaging API to the background script from the app is available on macOS only, not on iOS:

You can’t send messages from a containing iOS app to your web extension’s JavaScript scripts.

I wonder how can I change the settings and let background script know it needs to apply them.

Share Improve this question asked Mar 10 at 16:41 4ntoine4ntoine 20.5k25 gold badges113 silver badges239 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default -1

You can use an App Group to share data between your native app and your app extension. The app extension can communicate with your extension's background script.

One approach:

  • The user makes changes in your iOS app
  • The app saves this data in a UserDefaults suite
  • The background script requests setting values from your app extension at the appropriate time; for example your background script could request the data in an onBeforeNavigate handler.
  • Your app extension loads the defaults from the shared suite and provides this data to the background script.

本文标签: iosHow to enabledisable Safari Web Extension from the containing appStack Overflow