iOS通用链接:如果未安装应用,则打开商店链接

时间:2019-01-23 06:42:11

标签: ios deep-linking ios-universal-links

已成功将通用链接集成到应用程序中,如果未安装应用程序,请指导如何重定向到存储链接,请提出正确的使用方法

1 个答案:

答案 0 :(得分:0)

请尝试以下操作:

    guard let link = URL(string: sahareUrl) else { return }
    let dynamicLinksDomain = "name.page.link"
    let linkBuilder = FIRDynamicLinkComponents(link: link, domain: dynamicLinksDomain)
    linkBuilder.socialMetaTagParameters = FIRDynamicLinkSocialMetaTagParameters()
    linkBuilder.options = FIRDynamicLinkComponentsOptions()
    linkBuilder.options?.pathLength = .short
    linkBuilder.socialMetaTagParameters?.imageURL = URL(string: imagename)
    linkBuilder.iOSParameters = FIRDynamicLinkIOSParameters(bundleID: "yourBundleId")
    linkBuilder.iOSParameters?.appStoreID = "storeId"
    linkBuilder.iOSParameters?.iPadBundleID = "yourBundleId"
    linkBuilder.androidParameters = FIRDynamicLinkAndroidParameters(packageName: "packageNameOfAndroid")
    linkBuilder.socialMetaTagParameters?.title = title
    linkBuilder.socialMetaTagParameters?.descriptionText = description

    guard let longDynamicLink = linkBuilder.url else { return }
    print(longDynamicLink)

    FIRDynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { url, warnings, error in
        self.runOnUIThread {

            if url != nil{
                self.shareAds(item: [url!])
            }else{
                NVActivityIndicatorHelper.hideIndicatorInView()
            }
        }
    }

这可能会对您有所帮助。谢谢