Cannot access ManagedSettingsStore in extensions

Hi everyone,

I am trying to change the settings when the shield button is clicked. When I called let store = ManagedSettingsStore() in the ShieldAction extension, store.shield.applications is nil. How can I access the instance created in the host app?

Besides, has anyone ever tried to change the shield UI after clicking a button on the shield screen? I've searched around but no luck. is there any way I can notify the host app for further actions? Any help would be appreciated! Thank you very much.

Sorry I don't know why I can't add the wwdc21-10123 tag.

Answered by Frameworks Engineer in 718909022

Starting in iOS 16, settings from any ManagedSettingsStore instance will automatically be shared between a main app and its extensions. This means that you can edit settings you have set in the host app directly in the ShieldAction extension without any issue.

Regarding changing the shield configuration after selecting a button, the defer shield action immediately triggers a shield to be redrawn by calling the associated configuration(shielding:) method in the ShieldConfiguration extension's ShieldConfigurationDataSource. In there, you may change the configuration of the shield as you please.

Accepted Answer

Starting in iOS 16, settings from any ManagedSettingsStore instance will automatically be shared between a main app and its extensions. This means that you can edit settings you have set in the host app directly in the ShieldAction extension without any issue.

Regarding changing the shield configuration after selecting a button, the defer shield action immediately triggers a shield to be redrawn by calling the associated configuration(shielding:) method in the ShieldConfiguration extension's ShieldConfigurationDataSource. In there, you may change the configuration of the shield as you please.

Cannot access ManagedSettingsStore in extensions
 
 
Q