I am using firebase Deeplink URL to open my app's specific section. It is working well when app running in background but when I killed the app and click deeplink url from outside than I don't know how to handle that case, I mean where I should write my condition to get the parameters of url.
This method of app delegate called when app in background
@available(iOS 8.0, *)
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard let dynamicLinks = DynamicLinks.dynamicLinks() else {
return false
}
let handled = dynamicLinks.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
if let dynamicLink = dynamiclink, let _ = dynamicLink.url
{
var path = dynamiclink?.url?.path
path?.remove(at: (path?.startIndex)!)
let delimiter = "/"
var fullNameArr = path?.components(separatedBy: delimiter)
let type: String = fullNameArr![0]
let Id: String? = (fullNameArr?.count)! > 1 ? fullNameArr?[1] : nil
if(type == "games")
{
self.callGameDetailView(gameId: Id! , gameType: "created", notificationId: "NIL" )
}else{
var paths = dynamicLink.url?.path
paths?.remove(at: (path?.startIndex)!)
self.setRewardViewController(paths!)
}
} else {
// Check for errors
}
}
return handled
}
but it will not call open url method when I killed the app and hit the dynamic link url:
@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])
-> Bool {
return self.application(application, open: url, sourceApplication: nil, annotation: [:])
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
let dynamicLink = DynamicLinks.dynamicLinks()?.dynamicLink(fromCustomSchemeURL: url)
if let dynamicLink = dynamicLink
{
var path = dynamicLink.url?.path
path?.remove(at: (path?.startIndex)!)
let delimiter = "/"
var fullNameArr = path?.components(separatedBy: delimiter)
let type: String = fullNameArr![0]
let Id: String? = (fullNameArr?.count)! > 1 ? fullNameArr?[1] : nil
if(type == "games")
{
self.callGameDetailView(gameId: Id! , gameType: "created", notificationId: "NIL" )
}else{
var paths = dynamicLink.url?.path
paths?.remove(at: (path?.startIndex)!)
self.setRewardViewController(paths!)
return true
}
}
return FBSDKApplicationDelegate.sharedInstance().application(
application,
open: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
In short I have no Idea how to handle the dynamic link when app runs first time or run after killing the app?