passingnil
passingnil

Reputation: 413

How to oppen base application from extension in iOs

I'm trying to open base application from iMessage app, which is an extension in my xcode project(added as target app). Im using[self.extensionContext openURL:url completionHandler::^(BOOL success) {}];

but it doesn't work. here is info.plist in base app

here is info.plist in imessages extension

Am i doing something wrong ?

Upvotes: 0

Views: 215

Answers (2)

passingnil
passingnil

Reputation: 413

Actually i found the right answer. I was opening base app from another viewController using the extensionContext property of MSMessagesAppViewController, but that viewController was presenting on top of the rootVC. It happens that rootVC opens urls very well, but any other doesn't. So i simply request my rootVC to open url using extensionContext.

Upvotes: 0

Bilal
Bilal

Reputation: 19156

You can use this function.

UIApplication.shared.open(url, options: [:], completionHandler: nil)

But now you will get compiler error. To fix the compiler error, do this. Set Require Only App-Extension-Safe API to NO in your extension's build settings.

enter image description here

Upvotes: 2

Related Questions