I'm trying to open a deep link from my today extension widget to my main app with no luck.
//ExtensionViewController.swift
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let url = URL(string: "ACTION_TODAY://")
self.extensionContext?.open(url!, completionHandler: { (completed) in
})
}
Info.plist of the main app : (I guess ACTION_TODAY://
is not needed, but ACTION_TODAY
alone gives me the same result)
//AppDelegate.swift
func application(_ application: UIApplication, open url: URL,
sourceApplication: String?, annotation: Any) -> Bool {
let action_today = "ACTION_TODAY://"
if url.absoluteString.contains(action_today) {
return true
}
return false
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let action_today = "ACTION_TODAY://"
if url.absoluteString.contains(action_today) {
return true
}
return false
}
When I select one of the item of the collectionView displayed in the today extension, the console gives me a __55-[_NCWidgetExtensionContext openURL:completionHandler:]_block_invoke failed: Error Domain=NSOSStatusErrorDomain Code=-50 "(null)"
In today view controller, put the following code where you need to open the main iOS app from the extension.
let appURL = NSURL(string: "StarterApplication://")
self.extensionContext?.open(appURL! as URL, completionHandler:nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With