'Firebase Dynamic Links not working Every Time Open Custom WebView (Redirection issue) Swift

I'm using firebase dynamic links for creating links and share it from my app to social media platforms, I tried to share on WhatsApp and messenger and it's working great no problems.

The only exception when trying to open a link from Facebook, it opens the InAppBrowser first after that it's working perfectly some time and show popup to leave the Browser and open app but some time show preview page in case the app already installed. Some time show direct web page which backend team set in the redirection.

Here's the code for sharing and initiate:

func createLinkShare1(dynamicLinksDomainURIPrefix:String,link:URL) {
    let appBundleID = AppInformation.AppBundleId
    if let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) {
        linkBuilder.navigationInfoParameters = DynamicLinkNavigationInfoParameters()
        linkBuilder.navigationInfoParameters?.isForcedRedirectEnabled = true
        linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: appBundleID)
        linkBuilder.iOSParameters?.appStoreID = AppInformation.AppStoreId
        linkBuilder.iOSParameters?.minimumAppVersion = AppInformation.AppMinimumVersion
        linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: appBundleID)
        linkBuilder.androidParameters?.minimumVersion = 0
        linkBuilder.socialMetaTagParameters = DynamicLinkSocialMetaTagParameters()
        linkBuilder.socialMetaTagParameters!.title = "Testing "
        linkBuilder.socialMetaTagParameters!.descriptionText = "Invite You"
        guard let longDynamicLink = linkBuilder.url else {
            print("ERROR in linkBuilder")
            return
        }
        DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { url, warnings, error in
            if let error = error {
                print("error shortening link: \(error.localizedDescription)")
                return
            }
            if let url = url {
                print("Share Url = ",url)
                return
            }
        }
    }
}

Output:-

  1. iOS 14.5

Screenshot

  1. iPhone X (iOS 15.0.1)

ScreenShot

In Second case already app installed, i don't know why the preview page open instead of popup

  1. iPhone XR (iOS 15.1)

ScreenShot

  1. Facebook Redirection gif.

Gif

Sorry For hidden details.

I have tested with multiple devices and different version. Only the Deep linking working in below iOS15.

Can someone please explain to me how to show popup or deep working as expected in the Facebook case, I've tried to with above code but no results yet.

Any help would be greatly appreciated.

Firebase Dynamic Links not working iOS 15.1 Facebook Swift

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source