I'm trying to open my mother app from message extension on a click of button. I've used this code in my exstension:
@IBAction func open(_ sender: UIButton) {
let url = URL(string: "swiftexamples://")
self.extensionContext?.open(url!, completionHandler: {(succes) in })
}
Everything works fine when my mother app is running and backgrounded, however when i want to open closed app, it crashes. There are no crash logs, i have simmilar situation to this iOS app crashes when first opened by URL Scheme . I'm quite sure i have to add something to app delegate. I've found function application(_:open:options:). The problem is, i don't now how to implement "option" part. I've written this:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let url = launchOptions?[UIApplicationLaunchOptionsKey.url] as? NSURL
let sourceApp = launchOptions?[UIApplicationLaunchOptionsKey.sourceApplication] as? String
let annotation = launchOptions?[UIApplicationLaunchOptionsKey.annotation] as? AnyObject
self.application(application, open: url, options:[sourceApp: String, annotation:AnyObject] )
return true
}
Also i've heard about Universal Links and that they have similar abilities to url schemes. Is it possible to do achive what i want using universal links ?