157239669: dynamicLink nil upon first app install
Xcode version: 11.3.1 Firebase SDK version: 6.19 Firebase Component: DynamicLinks
I tried to create dynamicLink at Firebase console to navigate user to download my app at appStore, and when they launch app for the first time I keep getting DynamicLink object with nil url. func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool{
let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
// Redirect user to specific screen according to requirement.
DynamicLinks.performDiagnostics(completion: nil)
print("dynamic link :: \(String(describing: dynamiclink))")
print("Dynamic link : \(String(describing: dynamiclink?.url))")
if dynamiclink?.url != nil{
// self.logFirebaseAnaylyticsEvent(url: dynamiclink!.url!)
self.logFirebaseAnaylyticsReopenEvent(url: dynamiclink!.url!)
}
// let path = dynamiclink?.url?.path
// if path == "/home" {
// print("Redirect to home screen")
// }else{
// print("Redirect to another screen")
// }
}
if !handled {
// Show the deep link URL from userActivity.
let message = "continueUserActivity webPageURL:\n\(userActivity.webpageURL?.absoluteString ?? "")"
showDeepLinkAlertView(withMessage: message)
}
if handled == false{
UserDefaultStore.DeepLinkingURL = ""
}
return handled
} Optional(<FIRDynamicLink: 0x28205af80, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)
I found a few problems with this issue:
- I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
- This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.
Xcode version: 11.3.1 Firebase SDK version: 6.19 Firebase Component: DynamicLinks
I tried to create dynamicLink at Firebase console to navigate user to download my app at appStore, and when they launch app for the first time I keep getting DynamicLink object with nil url. func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool{
let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
// Redirect user to specific screen according to requirement.
DynamicLinks.performDiagnostics(completion: nil)
print("dynamic link :: \(String(describing: dynamiclink))")
print("Dynamic link : \(String(describing: dynamiclink?.url))")
if dynamiclink?.url != nil{
// self.logFirebaseAnaylyticsEvent(url: dynamiclink!.url!)
self.logFirebaseAnaylyticsReopenEvent(url: dynamiclink!.url!)
}
// let path = dynamiclink?.url?.path
// if path == "/home" {
// print("Redirect to home screen")
// }else{
// print("Redirect to another screen")
// }
}
if !handled {
// Show the deep link URL from userActivity.
let message = "continueUserActivity webPageURL:\n\(userActivity.webpageURL?.absoluteString ?? "")"
showDeepLinkAlertView(withMessage: message)
}
if handled == false{
UserDefaultStore.DeepLinkingURL = ""
}
return handled
}
Optional(<FIRDynamicLink: 0x28205af80, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)
I got exactly this same issue, I've been trying to solve it since yesterday.
The handleUniversalLink method returns true, but in the completion closure the dynamiclink.url property is nil.
It also seems to happen retroactively in older versions of my app, where I'm absolutely sure it was working.
AFAIK there have been no recent changes in the client SDK. @dmandar, are you aware of any backend changes that could be causing pending links to not be matched properly?
No recent changes in the client. Morgan, can you file a bug for Max to take a look at? Thanks.
Will do. In the meantime, @DracoRubi @nunepradeepkumar can you confirm that dynamic links work correctly otherwise? (i.e. when clicking a link with the app already installed, the link is correctly populated)
Filed b/151846783
In my case, the following happens:
If the dynamic link is clicked from a native iOS application, like Safari, Notes or the camera (reading a QR containing the link), it doesn't work.
In this case, this method is invoked in the AppDelegate:
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool
And as per your documentation, the link is processed with:
DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL)
userActivity.webpageURL holds the expected value, but calling the handler fails somehow and the result is nil, as indicated above.
However, if I use another application (Firefox, for example), it does work.
In this case, this method is invoked in the AppDelegate:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
And as per your documentation, the link is processed with:
DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
With no issues, it works perfectly.
EDIT: Added more info!
Will do. In the meantime, @DracoRubi @nunepradeepkumar can you confirm that dynamic links work correctly otherwise? (i.e. when clicking a link with the app already installed, the link is correctly populated)
when clicking a link with the app already installed, the link is correctly populated but received dynamic URL is Optional(<FIRDynamicLink: 0x280455740, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)
Same issue here.
Clicking on a dynamic link from the Notes app with the app already installed results in the Firebase SDK to send me a FIRDynamicLink containing a nil url.
The app triggering the dynamic link doesn't seem to have an impact for me:
- from Notes it opens my app with a nil FIRDynamicLink.url
- from Messenger or duckduckgo it opens a web page with an "open" button redirecting to my app wtih a nil FIRDynamicLink.url
same issue here (<FIRDynamicLink: 0x280455740, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>)
I see this issue with the app installed. I have a https://...pages.link deep link I tap in Notes, which takes me to my app right away In there, I call the FIRDynamicLinks API to handle the deep link, and it returns <FIRDynamicLink: 0x280455740, url [(null)], match type: unique, minimumAppVersion: N/A, match message: (null)>
We've seen this issue before when the end user opts out save my place in the app (the check box) for pasteboard. @amaurydavid @nunepradeepkumar @DracoRubi can you make sure the user testing this feature hasn't opted out on the app preview page?
Also, when the link is handled, can you check the device's pasteboard contents to see if the dynamic link is present?
No opting-out, the issue still happens.
And when the link is handled, the pasteboard isn't altered
To clarify, the checkbox needs to be filled:

Can you check that it's filled in?
Where did you get this screenshot from ? I don't remember seeing this page.
Where did you get this screenshot from ? I don't remember seeing this page.
It should open if you use the dynamic link without your app installed, or if you press down the link for a while and then select "Open in Safari".
To clarify, the checkbox needs to be filled:
Can you check that it's filled in?
what if we tell the dynamic link to skip this page?
Then the dynamic link will always fall back to a weak match.
Then the dynamic link will always fall back to a weak match.
What if that page isn't shown? For example, if the user already has the app installed, Safari will automatically open the app without showing that page. Will it fall back to a weak match?
@DracoRubi in that case it'll open the app directly through the system universal link behavior and you'll be able to get the URL from the system callbacks. Dynamic Links rely on the preview page to guarantee strong matching, and it does so by copying the URL to clipboard which the SDK then inspects when the app is opened.