Open parent app from ShieldAction extension in iOS

When I tap on one of the buttons in the ShieldAction extension I want to close the shield and open the parent app instead of the shielded app. Is there any way of doing this using the Screen Time API?

class ShieldActionExtension: ShieldActionDelegate {
  
  override func handle(action: ShieldAction, for application: ApplicationToken, completionHandler: @escaping (ShieldActionResponse) -> Void) {
    // Handle the action as needed.
     
    let store = ManagedSettingsStore()
         
    switch action {
    case .primaryButtonPressed:
      //TODO - open parent app

      completionHandler(.defer)
    case .secondaryButtonPressed:
      //remove shield
      store.shield.applications?.remove(application)
      completionHandler(.defer)
   

    @unknown default:
      fatalError()
    }
  }  
}
Post not yet marked as solved Up vote post of mariusgab Down vote post of mariusgab
2.2k views

Replies

Launching your parent app from your Shield Action extension is not currently supported. Please use Feedback Assistant to request an enhancement to the API.

Hello, Unfortunately, with the new iOS 17 and XCode 15 Beta this new feature is not supported.

Disappointed that this hasn't been added with iOS 17. Seems like a pretty simple and meaningful addition.

  • Agreed fully, @thomas_maht. Adding feedback to Apple in the hopes that they throw in this tweak as it seems like an easy win / low-hanging fruit for a substantial improvement on the ManagedSettingsUI API.

Add a Comment

Can we not just support opening a deep linked URL to our app from the shield extension?

  • Hello, UIApplication.shared.open(url) is not accessible from a shield extension.

  • Good point, @sadasdasrewrew. This seems like an important feature for Shield Actions. ManagedSettingsUI should be able to support opening the parent app for the shield. Hopefully this will be implemented by Apple soon enough, as it seems straightforward enough. I hope that people seeing this will also leave feedback so that it is implemented more quickly.

Add a Comment

There should be a workaround, however I couldn't figure it out yet. The one-sec App for example is using exactly what is described here. It seems like the app launches itself through the shielding with a custom deeplink. I have tried opening my own app through the openURL property in the Environment and with NSExtensionContext. Here's what I've tried:

Opening through Environment

@Environment(\.openURL) var openURL
override func handle(action: ShieldAction, for application: ApplicationToken, completionHandler: @escaping (ShieldActionResponse) -> Void) {
    // Handle the action as needed.
    switch action {
    case .primaryButtonPressed:
      openURL.callAsFunction(YourAppDeeplink)
// other code
}

Opening with NSExtensionContext

private func openApp(with url: URL) {
    let context = NSExtensionContext()

    context.open(url, completionHandler: nil)
}

However, neither approach has been successful in launching the app as intended. The one-sec App using this feature implies, that there must be a workaround or alternative method that we're missing.

@Maximillian-Dev Were you able to find a workaround for this? I am running into the same issue.

Add a Comment

https://apps.apple.com/us/app/app-lock/id6448239603 &

https://apps.apple.com/us/app/applocker-passcode-lock-apps/id1132845904

These apps are somehow doing, opening the parent app Shield Action.

Is there any way to do so? also when I lock app and click on app, Shield Config UI is not coming, default UI is coming.