代码之家  ›  专栏  ›  技术社区  ›  Akaanksha

通过AppStore打开应用程序时,分支深度链接不工作

  •  1
  • Akaanksha  · 技术社区  · 7 年前

    嗨,我在iOS应用程序中使用branch进行深度链接。 如果未安装应用程序,则会将用户重定向到AppStore。

    分支机构的文档表明,如果应用程序被重定向到AppStore,我们仍然可以向其发送某些参数。(像正常情况一样)但它不起作用。当应用程序在appstore安装后打开(重定向到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
        }
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Akaanksha    7 年前

    分支机构得到了惊人的支持。他们会回答你的每一个问题。在我通过邮件与他们进行了所有讨论之后。我用树枝找出了我的深链环孔在哪里。

    我们从后端发送的链接包括 . 当我们用符号替换反斜杠时,它开始工作了。