首页 文章

分支深层链接未打开应用程序

提问于
浏览
22

我一直在尝试(不成功)使用Branch来实现我们iOS应用程序的深层链接 . 分支URL直接重定向到App Store,从不尝试打开应用程序 . 我肯定错过了什么 .

我做了什么:

  • 包含分支SDK(CocoaPods)已将 branch_key 添加到应用程序plist

  • 在应用程序plist中为URL类型添加了URL方案

  • 在项目和开发人员控制台中的App ID中启用了 Associated Domains .

  • 确保权利文件包含在构建中 .

  • 在AppDelegate中注册了深层链接处理程序

仪表板:设置 - >链接设置:

  • "Always try to open app"已选中

  • "IOS URI Scheme"设置为应用程序的自定义URI方案 .

  • "Enable Universal Links"已选中 .

  • 捆绑标识符和Apple App前缀均已正确设置 .

在Branch Dashboard中的“Marketing”选项卡下,我创建了一个链接 . 我正在通过电子邮件将此链接发送给自己并在设备上打开它(Mail.app) . Safari打开,然后打开App Store,就像没有安装应用程序一样 .

application:openURL:sourceApplication:annotationapplication:continueUserActivity:restorationHandler 都没有被调用 .

AppDelegate方法:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let branch: Branch = Branch.getInstance()
    branch.initSessionWithLaunchOptions(launchOptions, andRegisterDeepLinkHandler: { params, error in
        if (error == nil) {
            // 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 ...
            NSLog("params: %@", params.description)
        }
    })
    return true
}

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
    // pass the url to the handle deep link call

    return Branch.getInstance().continueUserActivity(userActivity)
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    // pass the url to the handle deep link call
    Branch.getInstance().handleDeepLink(url);

    // do other deep link routing for the Facebook SDK, Pinterest SDK, etc
    return true
}

我错过了配置步骤吗?这是因为应用程序是通过Xcode调试而不是通过应用程序商店安装的?我期待看到调用应用程序委托方法,但它们不是 .

3 回答

  • 1

    似乎必须通过App Store / Test Flight / Ad Hoc安装应用程序,否则将不会考虑安装该应用程序 .

    我使用Ad Hoc配置将应用程序安装到我的设备上,一切正常 .

  • 11

    对我来说,即使我在没有Adhoc发行版的情况下安装了tethered,链接也能正常工作 . 然后有一天它停止了工作 . 那是因为我在app中点击了前进链接到bnc .

    对此的修复很容易 - 只需长按链接即可 . 选项显示“在应用程序中打开” . 单击此按钮,链接由app处理 . 下一次,链接按预期工作,即使没有长按,因为Safari会记住这是默认行为 .

  • 12

    我也有同样的问题,但我的解决方案与你的不同 .

    注意:我们可以在调试模式下打开应用程序,(我做了它,正如上面评论部分中Alex Bauer所指出的那样) .

    .plist 中,我添加了两个不同的键,一个是 live ,另一个是 test (同时),以及上面提到的配置设置 .

    我正在使用的深层链接域名就是这个 . bnc.lt . 我就我的问题邮寄给Branch Io支持团队,然后得到如下答复'

    您遇到问题的原因是因为您仍然使用我们传统的bnc.lt链接域 . 这个链接域在过去一年中逐渐被淘汰 . 开发和功能已经停止了一段时间,支持我们的新链接域(app.link) . 要解决您的问题并使您的AASA验证工具正常工作,您需要在分支仪表板(https://dashboard.branch.io/settings/link)上将链接域从bnc.lt更改为app.link . 完成此更改后,您需要更新应用以接受新的app.link链接域以及旧的bnc.lt链接域 . https://gist.github.com/ethanneff/a2a70d1b3518c638701c28b1bd374e80

    请访问以上链接,非常有帮助 .

    希望它能解决你的问题,Happy Branching :)

相关问题