如何解决FirebaseDynamicLink:长链接正常,但短链接无效
链接在Android应用中有效,但在iOS中,长链接有效,而短链接无效。
func handleDynamicLink(_ dynamicLink: DynamicLink?) -> Bool {
guard let dynamicLink = dynamicLink else { return false }
guard let deepLink = dynamicLink.url else { return false }
let queryItems = URLComponents(url: deepLink,resolvingAgainstBaseURL: true)?.queryItems
let invitedBy = queryItems?.filter({(item) in item.name == "invitedby"}).first?.value
let user = Auth.auth().currentUser
if user != nil
{
print("invitedBy:\(invitedBy ?? "nil")")
//Add to user's team
UserObject().addTeamMember(userId: invitedBy!,delegate: nil)
}
else
{
self.invitedBy = invitedBy!
}
return true
}
func application(_ app: UIApplication,open url: URL,options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
let sourceApplication = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String?
print("open url: \(url)")
if url.absoluteString == "newtask" {
NotificationCenter.default.post(name:NSNotification.Name("newtask"),object: nil)
}
if FUIAuth.defaultAuthUI()?.handleOpen(url,sourceApplication: sourceApplication) ?? false {
return true
}
if DynamicLinks.dynamicLinks().shouldHandleDynamicLink(fromCustomSchemeURL: url)
{
let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
print("dynamicLink: \(dynamicLink!.url?.absoluteString ?? "nil")")
return handleDynamicLink(dynamicLink)
}
// other URL handling goes here.
if url.scheme == "homescreen"
{
print("NavigatetoHomeScreen")
if let tabbarController = self.window?.rootViewController as? UITabBarController
{
tabbarController.selectedindex = 0
let planNavigationController = tabbarController.viewControllers![0] as! UINavigationController
planNavigationController.popToRootViewController(animated: false)
}
return true
}
else if url.scheme == "newtask"
{
print("NavigatetoNewTask")
if let tabbarController = self.window?.rootViewController as? UITabBarController
{
tabbarController.selectedindex = 0
let planNavigationController = tabbarController.viewControllers![0] as! UINavigationController
planNavigationController.popToRootViewController(animated: false)
planNavigationController.viewControllers[0].performSegue(withIdentifier: "toTask",sender: self)
}
return true
}
else
{
print("url.scheme : \(url.scheme ?? "nil")")
}
return false
}
我已将这些代码添加到didFinishLaunchingWithOptions
中FirebaSEOptions.defaultOptions()?.deepLinkURLScheme = Settings.deepLinkURLScheme
FirebaseApp.configure()
在info.plist中,我已经添加了这些
<key>CFBundleURLSchemes</key>
<array>
<string>homescreen</string>
<string>newtask</string>
<string>-----.page.link</string>
<string>https://-----.page.link</string>
<string>https://-----.me</string>
</array>
当我单击长链接时,它起作用,但短链接返回nil,并且出现类似“动态链接Web URL查询项为空”的错误
解决方法
确保您已将域名价值添加到关联的域中,例如“ dev.hnb.com”
// MARK: - Deep Linking
func application(_ application: UIApplication,continue userActivity: NSUserActivity,restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
{
let myUrl: String? = userActivity.webpageURL?.absoluteString
print(myUrl)
}
------------------------------------------------------------------------
AASA FILE FOR Verifies
--------------------
{
"applinks": {
"apps": [],"details": [
{
"appID": "******1738.com.app","components": [
{
"/": "/documentationsucksforios13","comment": "This documentation is awful"
},{
"/": "/customer/account/createpassword/*","?": { "_query_id": "?*" },"?": { "_query_token": "?*" },"?": { "id": "?*" },"?": { "token": "?*" }
},"?": { "token": "?*" }
}
],"paths": [ "/documentationsucksforios12" ]
}
]
},"webcredentials": {
"apps": [ "******1738.com.app" ]
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。