Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 9和x2B的Branch.io链接;问题_Ios_Swift_Deep Linking_Branch.io_Ios Universal Links - Fatal编程技术网

iOS 9和x2B的Branch.io链接;问题

iOS 9和x2B的Branch.io链接;问题,ios,swift,deep-linking,branch.io,ios-universal-links,Ios,Swift,Deep Linking,Branch.io,Ios Universal Links,我在我的项目中使用Branch.io从我的网站启动应用程序。我想要的是,如果应用程序关闭,当我点击网站上的通用链接时,它会首先打开主页。相反,它打开了另一个窗口。它在iOS 8上运行良好。但在iOS 9+中,它总是打开启动屏幕 请看一下我的代码: AppDelegate: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)

我在我的项目中使用Branch.io从我的网站启动应用程序。我想要的是,如果应用程序关闭,当我点击网站上的通用链接时,它会首先打开主页。相反,它打开了另一个窗口。它在iOS 8上运行良好。但在iOS 9+中,它总是打开启动屏幕

请看一下我的代码:

AppDelegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    let branch = Branch.getInstance()
    branch.initSessionWithLaunchOptions(launchOptions) { (params, error) -> Void in
      DHIndicator.hide()
      if let _ = params {
        print("kdlkasdlf: \(params.debugDescription)")
        if let str = params["$deeplink_path"], url = NSURL(string: str as! String) {
          NSLog("link: \(url)")
          self.path = url.path
          self.query = url.query
          LaunchAppFlowManager.shareInstance.displayLaunchDetails()
        } else {
          // load your normal view
        }
      }
    }
window = UIWindow(frame: UIScreen.mainScreen().bounds)
    window?.makeKeyAndVisible()
    window?.backgroundColor = UIColor.whiteColor()
    AccountFlowManager.shareInstance.start()
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    Branch.getInstance().handleDeepLink(url)
    if AppDelegate.shareInstance().window?.rootViewController?.nibName != "LaunchScreenVC" {
      DHIndicator.show()
    }
    return true
  }

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
    print(userActivity.webpageURL?.absoluteString)
    if AppDelegate.shareInstance().window?.rootViewController?.nibName != "LaunchScreenVC" {
      DHIndicator.show()
    }
    return Branch.getInstance().continueUserActivity(userActivity)
  }
和,func启动应用程序:

if let _ = AppDelegate.shareInstance().path, _ = AppDelegate.shareInstance().query {
        let navi = UINavigationController(rootViewController: HomePageVC())
        self.navi = navi
        AppDelegate.shareInstance().window?.rootViewController = navi
      } else {
        let vc = LaunchScreenVC()
        AppDelegate.shareInstance().window?.rootViewController = vc
      }

总结一下这个问题:

  • 在iOS 8上,单击分支链接时,应用程序将打开并显示 正确的ViewController
  • 在iOS 9上,当分支链接 单击应用程序将打开,但会显示默认的ViewController
  • 本例中的问题与通用链接有关。以前,在iOS 8上使用URI方案时,您可以使用$deeplink_path在应用程序内进行路由。与使用$deeplink_path不同,with Universal Links Branch现在建议使用存储在自定义字段中的链接数据来通知应用内路由决策,如下所述:


    此外,在Branch init completion块中定位用于应用内路由的代码非常重要,因为此完成块仅在收到来自Branch服务器的响应且链路参数可用后运行。如果应用内路由的代码位于完成块之外(且未被完成块调用),则很可能在Branch实际返回链接参数之前做出路由决策。

    Alex with Branch.io here:听起来您的应用中可能没有完全配置通用链接。我们可以看看您用于测试的示例链接吗?如果你不想公开分享这些信息,请放心吧!这里有两个测试链接:和。我也已经提交了一张票。所以请检查一下。我们会看一下,然后再给你回复。谢谢你的链接@请再检查一下我的电子邮件。我想我遇到了同样的问题@亚历克斯鲍尔,你能帮忙吗?