FirebaseDynamicLink:长链接正常,但短链接无效

问题描述

我正在构建一个具有邀请链接的应用。

链接在Android应用中有效,但在iOS中,长链接有效,而短链接无效。

这是我在appdelegate中处理动态链接代码

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”

enter image description here

// 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" ]
      }
    }