0

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 ?

passingnil
  • 403
  • 1
  • 5
  • 14

2 Answers2

2

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

Bilal
  • 18,478
  • 8
  • 57
  • 72
  • Hi, i did as you said and it works, but is this normal ? I mean it's extenssion, how it can use UIApplication class ? Also, can it cause problems in release build ? – passingnil Jun 05 '17 at 08:10
  • I don't think there will be any issues. – Bilal Jun 05 '17 at 14:57
0

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.

passingnil
  • 403
  • 1
  • 5
  • 14