Firebase Dynamic links - when clicked not working in iOS
Finally I am able to resolve the issue.
The initial step is to create a universal link in Firebase console.
Once the universal link is created , we have to do following changes in XCode:
- Enable associated domains under capablities
- Include URL types
- Must verify your Team ID that you would have provided in firebase console.
Once the universal link setup is completed in Xcode, we can do build and run and check the working of Universal link.
i.e. clicking the link should open the app (provided app is already installed).
and it should not open the safari browser.
If clicking the link opens safari browser , then there is a problem with the Universal link setup.
The below tutorial is very useful:
https://youtu.be/KLBjAg6HvG0
Firebase dynamic link won't open Appstore when the app is not installed
Actually, turns out on the code inside the app to generate the dynamic link does not have the playstore app id supplied, which explains why it only broken when opening playstore but it's okay when opening appstore.
Firebase short dynamic link not working in iOS (being treated as a deeplink)
It turns out I needed to install a Capacitor Dynamic Links package for the short links to work in iOS.
https://www.npmjs.com/package/@pantrist/capacitor-firebase-dynamic-links
All I need to was install it and add the following function and it worked fine:
FirebaseDynamicLinks.addListener('deepLinkOpen', (data) => {
console.log(data);
});
Before I was doing it like this:
import { App, URLOpenListenerEvent } from '@capacitor/app';
App.addListener('appUrlOpen', (data: any) => {
console.log(data)
});
Note:
The dynamic link only works from the app store (no app installed) if the dynamic link has the preview set to on.
Firebase dynamic link not opening iOS app
Steps:
- Delete your app
- Restart your device.
- Reinstall your app and test.
As per firebase, sometimes error comes while downloading "apple-app-site-association" file associated with your domain. That's why it happens.
Check out this video: https://youtu.be/KLBjAg6HvG0?t=483 for debugging help.
Setup Dynaminc link from start: https://www.youtube.com/watch?v=KLBjAg6HvG0
If you have completed the above-mentioned steps, please check if you have the right methods implemented in your AppDelegate file.
Method 1:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if DynamicLinks.dynamicLinks().shouldHandleDynamicLink(fromCustomSchemeURL: url) {
let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
self.handleDynamicLink(dynamicLink)
return true
}
return true
}
Method 2:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let incomingURL = userActivity.webpageURL {
print(incomingURL)
let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL) { (dynamicLink, error) in
guard error == nil else {
print("Found an error! \(error!.localizedDescription)")
return
}
if let dynamicLink = dynamicLink {
self.handleDynamicLink(dynamicLink)
}
}
if linkHandled {
return true
} else {
//May be do other things with our incoming URL?
return false
}
}
return false
}
Handle Dynamic Link common Method:
func handleDynamicLink(_ dynamicLink: DynamicLink?) {
guard let dynamicLink = dynamicLink else { return }
guard let deepLink = dynamicLink.url else { return }
}
Related Topics
How to Make Both Header and Footer in Collection View with Swift
How to Check Where My App Is Using Idfa
Dynamic Uiimageview Size Within Uitableview
Tableview Reloaddata VS. Beginupdates & Endupdates
Calculating Tiles to Display in a Maprect When "Over-Zoomed" Beyond the Overlay Tile Set
Implementing Auto Layout for Views Generated Programmatically
Swift - Uiimagepickercontroller - How to Use It
Installation Failed "Invalid Argument" When Trying to Run Today Application Extension
Loop Through Subview to Check for Empty Uitextfield - Swift
Xcode 4.2 Jumps to Main.M Every Time After Stopping Simulator
How to Use Cocoapods When Creating a Cocoa Touch Framework
iOS Get Heart Rate from Apple Watch in Near Real Time
Uiviewcontrollerhierarchyinconsistency When Trying to Present a Modal View Controller
Opengl Es 2.0 Object Picking on iOS
Corelocation Heading Base on Back Camera (Augmented Reality)
Are Afnetworking Success/Failure Blocks Invoked on the Main Thread
iOS Changing Uiscrollview Scrollbar Color to Different Colors