【发布时间】:2016-05-10 08:38:39
【问题描述】:
我一直在尝试(未成功)使用Branch 在我们的 iOS 应用程序中实现深度链接。分支 URL 直接重定向到 App Store,并且从不尝试打开应用程序。我一定是错过了什么。
我做了什么:
-
包含的分支 SDK (CocoaPods) 添加了
branch_key到应用程序 列表 -
在应用程序 plist 中为 URL 类型添加了 URL 方案
-
在项目和 App ID 中都启用
Associated Domains开发者控制台。 -
确保授权文件包含在构建中。
-
在 AppDelegate 中注册的深层链接处理程序
仪表板:设置 -> 链接设置:
-
选中“始终尝试打开应用”
-
“IOS URI 方案”设置为应用程序的自定义 URI 方案。
-
选中“启用通用链接”。
-
Bundle Identifier 和 Apple App Prefix 均设置正确。
在分支仪表板的“营销”选项卡下,我创建了一个链接。我正在通过电子邮件将此链接发送给自己并在设备 (Mail.app) 上打开它。 Safari 打开,然后 App Store 像未安装应用程序一样打开。
application:openURL:sourceApplication:annotation 和 application: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 调试而不是通过应用商店安装的吗?我希望看到调用的应用程序委托方法,但它们没有。
【问题讨论】:
-
我在 let branch 的行中遇到了 BAD EXCESS:Branch = Branch.getInstance() 在应用程序委托类中,你能对此提出建议吗,我也在使用 swift
-
@Nick : 你找到解决办法了吗?