The dynamic links used to be working fine both on actual device, and also in the simulator. When I click on the link in the simulator (or pasting it in safari), I get redirected to the ".page.link" site where it says "open" - and clicking open opens the app perfectly. However, if I repeat the same steps on my actual device, I get redirected to the support url, and nothing happens (app doesn't open even though its installed on my phone).
This is my code in where I display a url
if let uid = Auth.auth().currentUser?.uid {
guard let link = URL(string: "https://www.testapp.com/uid=" + uid) else {
return
}
let dynamicLinksDomain = "testapp.page.link"
let linkBuilder = DynamicLinkComponents(link: link, domain: dynamicLinksDomain)
linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.burgertralla.theGreat")
linkBuilder.shorten { (url, _, _) in
if let url = url {
self.shareTopLabel.text = url.absoluteString
}
}
}
And this is my AppDelegate:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
self.handleIncomingDynamicLink(dynamicLink: dynamicLink)
return true
}
return false
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if let incomingUrl = userActivity.webpageURL {
let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingUrl, completion: { (dynamicLink, _) in
if let dynamicLink = dynamicLink, let _ = dynamicLink.url {
self.handleIncomingDynamicLink(dynamicLink: dynamicLink)
}
})
if linkHandled {
return linkHandled
}
}
return false
}
func handleIncomingDynamicLink(dynamicLink: DynamicLink) {
guard let pathComponents = dynamicLink.url?.pathComponents else {
return
}
for pathComponent in pathComponents {
if pathComponent.contains("uid=") {
let uid = pathComponent.drop(prefix: "uid=")
Database.database().reference(withPath: "profile/" + uid).observeSingleEvent(of: .value) { (snapshot) in
if snapshot.exists(), var data = snapshot.value as? [String: Any] {
data["uid"] = snapshot.key
let userProfileVC = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "UserProfileViewController") as! UserProfileViewController
if let tabBarVc = self.window?.rootViewController as? UITabBarController {
tabBarVc.selectedIndex = 1
if let discoveryVC = tabBarVc.viewControllers?[1] as? UINavigationController {
userProfileVC.selectedUser = data
discoveryVC.pushViewController(userProfileVC, animated: true)
}
}
}
}
}
}
}
Do anyone have any clue on whats going on here?
Thanks for the help guys :)
EDIT : It does work on my iPhone with Chrome, however not with Safari. I don't know why...