Reputation: 123
My Dynamic link works for the most part, and its all done programmatically:
However I want to add that if user doesn't have my app installed, then I want it to be redirected to the App Store, to display my app.
How can I add this programmatically? I know I can create a dynamic link under the link prefixes, that will behave the way I want it to - but I want to do it programmatically since I have constructed the behavior of the link already programmatically.
Thanks guys.
This is my code in where the users can share their link:
@IBAction func shareFirstButton(_ sender: UIButton) {
if let uid = Auth.auth().currentUser?.uid {
guard let link = URL(string: "https://www.testApp123.com/uid=" + uid) else {
return
}
let dynamicLinksDomain = "testApp123.page.link"
let linkBuilder = DynamicLinkComponents(link: link, domain: dynamicLinksDomain)
linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.burgertralla.myTestApp")
linkBuilder.shorten { (url, _, _) in
if let url = url {
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)
}
}
}
}
Upvotes: 0
Views: 2143
Reputation: 12877
Ensure that your app's App Store ID and your App ID prefix is specified in your app's settings. To view and edit your app's settings, go to your Firebase project's Settings page and select your iOS app.
Confirm that your Firebase project is properly configured to use Dynamic Links in your iOS app by opening the apple-app-site-association file that is hosted on your Dynamic Links domain. For example:
https://example.page.link/apple-app-site-association
If your app is connected, the apple-app-site-association file contains a reference to your app's App Store ID and bundle ID. For example:
{"applinks":{"apps":[],"details":[{"appID":"1234567890.com.example.ios","paths":["/*"]}]}}
If the details property is empty, double-check that you specified your App ID prefix. Note that your App ID prefix may not be the same as your Team ID.
Upvotes: 1