I am trying to use Firebase Dynamic links in an iOS App, but they're not working correctly on first install - I get
Deep Link does not contain valid required params. URL params: {
"match_message" = "No pre-install link matched for this device.";
"request_ip_version" = "IP_V4";
}
printed to the console.
Steps to reproduce:
- Click Dynamic Link on webpage
- Click "Open" on the preview page
- Once App Store opens, install app from XCode
- Click "Paste"
If the app is already installed, I do not get the preview page, the link opens the app and I'm able to read the info from the link, so I believe my applinks and domains are all set up correctly.
I have tried setting both of these to NO in info.plist
- FirebaseDeepLinkPasteboardRetrievalEnabled
- FirebaseAppDelegateProxyEnabled
but that doesn't make a difference (except I no longer get the "Paste" pop-up with PasteboardRetrieval disabled.)
I have tried adding an appDelegate and sceneDelegate, and overriding methods. The following gets hit on first install:
class SceneDelegate: NSObject, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
print(connectionOptions.urlContexts.first?.url)
print(connectionOptions.userActivities.first?.webpageURL)
print("SceneDelegate is connected!")
}
These lines print before the Deep Link does not contain... message, but I get nil back for the print(connectionOptions... lines.
If paste is enabled, these lines print, then I get the paste pop up, then I get the Deep link does not... message.
None of the other "Entry point" methods are getting hit (on first open / install).
We use a custom domain for Firebase Dynamic links: https://l.example.com, and these links redirect to https://www.example.com/?link_params_i_care_about.
Both https://l.example.com and https://www.example.com are added as associated domains, and under FIRDLAddToAllowListForCustomDomainsArray
Am I missing something, or have apple killed Dynamic Links on iPhone 2 years before Google kill it completely?
UPDATE
I had misconfigured my info.plist, using the string FIRDLAddToAllowListForCustomDomainsArray instead of FirebaseDynamicLinksCustomDomains - that has fixed the Deep Link does not contain... message.
However, I'm still not getting any of my delegate methods being hit. Firebase is clearly reading the clipboard, and now successfully parsing the dynamic link, but then doesn't appear to be doing anything with it.
If I put the following code in my appDelegate didFinishLaunchingWithOptions then it triggers the "Allow Paste" dialog to appear earlier, but successfully reads the link from the clipboard, parses it and allows me to do what I need.
if let str = UIPasteboard.general.string {
if let url = URL(string: str) {
if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromUniversalLink: url) {
handleDynamicLink(dynamicLink)
}
}
}
However, this feels like a hacky workaround, and would need to combine it with an isFirstLaunchAfterInstall check to ensure it only ever runs once.
What am I missing, why are none of the delegate methods being hit?
For reference, once the app is installed and a deep link followed, the onOpenUrl completion handler (on my ContentView) gets calls. This is what the google example shows to use for Dynamic Links in a SwiftUI app, but it's not getting called after the user allows paste, and neither are any of the methods in my app or scene delegates.