Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent Application Opening #5

Open
haider792 opened this issue Aug 20, 2024 · 11 comments
Open

Parent Application Opening #5

haider792 opened this issue Aug 20, 2024 · 11 comments

Comments

@haider792
Copy link

haider792 commented Aug 20, 2024

Is it possible that we can open the parent application from the shield.
i have a functionality that when the user click on the primary button on shield action extension it opens the parent app(App who has installed the restrcition on another app).

same thing is happenin in jomo app. @NoodleOfDeath

@NoodleOfDeath
Copy link
Owner

Ugh. Unfortunately, I have researched all possible ways to make this possible and Apple just has not made it even natively doable. Like you can't even open your app "schema" because opening URLs from the main bundle is not accessible to the Shield extensions :( pretty lame right?

@haider792
Copy link
Author

but how jomo app is doing then? any rough idea.
they are creating a perfect scenario.

@NoodleOfDeath
Copy link
Owner

interesting. you're right. i'll have to dig into that a bit more 🤔

@haider792
Copy link
Author

let me know if you find anything.

@NoodleOfDeath
Copy link
Owner

NoodleOfDeath commented Aug 20, 2024

try using the NSEXtensionContext to call openURL

@NoodleOfDeath
Copy link
Owner

NoodleOfDeath commented Aug 20, 2024

give this hacky solution a shot... in your ShieldAction. You also need to add your URL scheme to your Info.plist and handle for all three delegate methods not just for app token

  override func handle(action: ShieldAction, for application: ApplicationToken, completionHandler: @escaping (ShieldActionResponse) -> Void) {
    // Handle the action as needed.
    switch action {
    case .primaryButtonPressed:
      completionHandler(.close)
    case .secondaryButtonPressed:
      completionHandler(.defer)
      if let url = URL(string: "your-app-schema://") {
        // hack option 1
        let webView = WKWebView()
        webView.load(URLRequest(url: url))
        // hack option 2
        let context = NSExtensionContext()
        context.open(url)
      }
    @unknown default:
      fatalError()
    }
  }

@haider792
Copy link
Author

have you tried it? its not working on my side.
@NoodleOfDeath

@haider792
Copy link
Author

haider792 commented Aug 21, 2024

have you searched it out more or have you done the testing on code you shared?
becuase its not opening the parent(Host) application on triggering the secondary button on my side.

@NoodleOfDeath

@NoodleOfDeath
Copy link
Owner

So I have tried doing quite a bit more research and it's practically impossible to find a way for this to work natively so far

@AftabUfaq
Copy link

i want to get the screen time used.

@NoodleOfDeath
Copy link
Owner

i want to get the screen time used.

Uh. are you having issues making the library features work? or are you having issues with this particular "feature" why seems to only be achieveable by using non public methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants