Launch Host App from Share Extension

Hi!

Could you please point me to the official documentation or recommended approach for launching the host app from a Share Extension?

The scenario is:

The user is sharing some text to my app.

I need launch App and show this text.

At the moment, I'm using the following hack:

let selector = NSSelectorFromString("sharedApplication")
if let app = UIApplication.perform(selector)?.takeUnretainedValue() as? UIApplication,
app.responds(to: #selector(UIApplication.open(_:options:completionHandler:))) {
app.open(url, options: [:], completionHandler: nil)
}

This does work, but it's terrible.

So, the question: What is the official way to open the host app from within a Share Extension?

Thanks!

Answered by DTS Engineer in 833610022

You have to be careful about terminology here. When talking about extensions in the Apple ecosystem:

  • The host app is the one using the extension.

  • The container app is the one in which the extension is buried.

I believe you’re trying to launch the container application. If so, there isn’t a supported way to do this. See this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

You have to be careful about terminology here. When talking about extensions in the Apple ecosystem:

  • The host app is the one using the extension.

  • The container app is the one in which the extension is buried.

I believe you’re trying to launch the container application. If so, there isn’t a supported way to do this. See this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Launch Host App from Share Extension
 
 
Q