Firebase动态长链接在iOS中不可解析

时间:2019-06-07 10:56:50

标签: ios swift firebase firebase-dynamic-links

我有一些链接可以分享,其中包含使用深层链接的法语字符。 我正在使用.urlPathAllowed编码url字符串,也已经使用.urlHostAllowed进行了测试。 但是一直在创建长时间的链接,但在创建简短的链接时却出现了

的错误

“操作无法完成。长链接无法解析:https://long.encoded/url [https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_parameters]

这是我的通过短网址使用动态链接的代码。

var sharingURL = "https://www.example.com/fr/something/traversée-des-alpes-de-chamonix-à-briançon-512/"
sharingURL = sharingURL.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? sharingURL
guard let link = URL(string: sharingURL) else { return }

let dynamicLinksDomain = kSharingDomain
let linkBuilder = DynamicLinkComponents(link: link, domain: dynamicLinksDomain)
linkBuilder.navigationInfoParameters?.isForcedRedirectEnabled = true
linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.bundle.identifier")
linkBuilder.iOSParameters?.appStoreID = kAppStoreID
linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: "com.android.package")
linkBuilder.analyticsParameters = DynamicLinkGoogleAnalyticsParameters(source: "source", medium: "medium", campaign: "campaign")
linkBuilder.socialMetaTagParameters = DynamicLinkSocialMetaTagParameters()
linkBuilder.socialMetaTagParameters?.title = "Some title"
linkBuilder.socialMetaTagParameters?.descriptionText = "Some long desription"
linkBuilder.socialMetaTagParameters?.imageURL = URL(string:arrSportImages[0]["image"] as! String)!
guard let longDynamicLink = linkBuilder.url else { return }
DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { url, warnings, error in
    // Share link
    if let url = url {
        let objectsToShare = [url] as [Any]
        let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
        activityVC.popoverPresentationController?.barButtonItem = sender
        self.present(activityVC, animated: true, completion: nil)
    }
    else {
        print(error?.localizedDescription)
    }
}

请帮助我解决此问题。

0 个答案:

没有答案