【问题标题】:Branch Deep Linking not working when opening app through AppStore通过 AppStore 打开应用程序时,分支深度链接不起作用
【发布时间】:2017-09-22 07:23:42
【问题描述】:

您好,我在我的 iOS 应用程序中使用分支进行深度链接。 如果安装了应用程序,深层链接会打开,应用程序会显示与初始视图控制器不同的视图控制器。 如果未安装应用程序,用户将被重定向到 AppStore。

Branch 的文档说,如果应用程序被重定向到 AppStore,我们仍然可以向它发送某些参数。(像往常一样)但它不起作用。当应用程序在安装应用商店后打开时(重定向到应用商店后),它不会打开新的视图控制器,它通过分支正常打开;s 深度链接(当应用程序已经在 iPhone 中时)。

我的代码如下:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    UserDefaults.standard.set(false, forKey: "isDataSynced")
    UserDefaults.standard.setSecret(securePassword)
    //        UserDefaults.standard.set(false, forKey: "DeviceIdentifiersSavedInDB")
    CommonFunctions.sharedCommonFunctions.setUpSideMenu()
    UserDefaults.standard.set(false, forKey: "fromBranch")

    Branch.getInstance().initSession(launchOptions: launchOptions) { params, error in
        // params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
        // params will be empty if no data found
        // ... insert custom logic here ...
        if error == nil {
        print(params as? [String: AnyObject] ?? {})
            if let parameters = params as? [String : AnyObject] {
                if let link = parameters["~referring_link"] as? String {
                    if self.validateURL(url: URL(string: link)!) {
                        UserDefaults.standard.set(false, forKey: "declinedTermsConditions")
                        UserDefaults.standard.set(true, forKey: "fromBranch")
                        let initialViewController = self.mainStoryboard.instantiateViewController(withIdentifier: "CustomSideMenuControllerViewController") as! CustomSideMenuControllerViewController
                        self.window?.rootViewController = initialViewController
                    }
                }
            }
        }
    }

    if UserDefaults.standard.value(forKey: udiBarcode) == nil {
          } else {
        //Navigate to DashBoard VC
        let initialViewController = mainStoryboard.instantiateViewController(withIdentifier: "CustomSideMenuControllerViewController") as! CustomSideMenuControllerViewController
        self.window = UIWindow(frame: UIScreen.main.bounds)
        self.window?.rootViewController = initialViewController
        self.window?.makeKeyAndVisible()
    }

    UserDefaults.standard.set( "true" , forKey: "isFirstTimeAutomationTest")
    Fabric.with([Crashlytics.self])

    return true
}


 func application(_ application: UIApplication,
                     continue userActivity: NSUserActivity,
                     restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
         Branch.getInstance().continue(userActivity)
        return true
    }


 func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        // pass the url to the handle deep link call
      Branch.getInstance().handleDeepLink(url)
        return true
    }

【问题讨论】:

  • 有 Branch 团队的人员在 StackOverflow 中监控问题。可能想打开 Branch 支持票以获得更多关注。

标签: ios iphone branch deep-linking ios-universal-links


【解决方案1】:

分支机构有惊人的支持。他们回答您的每一个查询。在我与他们在邮件中进行了所有讨论之后。我发现使用分支进行深度链接的漏洞在哪里。

我们从后端发送的链接包含 反斜杠(**) 而分支接受 **& 符号 (&)。当我们用 & 号替换我们的反斜杠时,它开始工作了。

【讨论】:

  • 你能分享任何教程吗,如何使用它。当我没有通过深度链接安装应用程序时,我对如何打开 AppStore 感到困惑。
猜你喜欢
  • 1970-01-01
  • 2016-06-26
  • 2016-05-10
  • 1970-01-01
  • 1970-01-01
  • 2017-11-16
  • 2020-05-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多