我使用Branch.io为我的项目从我的网站启动应用程序。我想要的是,如果应用程序关闭,当我点击网络上的通用链接时,首先会打开主页。相反,它打开了另一个。它适用于iOS 8,但在iOS 9+中,它始终打开LaunchScreen。适用于iOS 9及以上版本的Branch.io链接
请看看我的代码:
的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
}
亚历克斯与Branch.io在这里:它听起来像通用链接可能没有完全配置在您的应用程序。我们能否看到您用于测试的示例链接?如果您不想公开分享这些信息,请随时[提交支持请求](https://support.branch.io)! –
这里有两个测试链接:https://8obj.app.link/stream?$deeplink_path=onedoor /onedoor/stream?id = 1/undefined和https://8obj.app.link/stream?$ deeplink_path = onedoor:// onedoor /流ID = 1/617c30ed70384800d838417b68d1e7ab。我也已经提交了一张票。所以请检查。 –
我们会看看并回复你。感谢您的链接! –