私たちのiOSアプリケーションでディープリンクを実装するためにBranchを使用しています。今私は、アプリケーションを実行し、ブランチでリンクを介してそれを開こうとすると、branch.initSession
が呼び出され、私は深いリンクのデータにアクセスすることができます。しかし、アプリケーションが起動していないときにブランチリンクを直接開こうとすると、branch.initSession
からのandRegisterDeepLinkHandler
コールバックが実行されません。これは基本的にディープリンクのポイントを無効にします。`Branch.initSession`は、アプリケーションがリンクから起動されたときに` andRegisterDeepLinkHandler`コールバックを呼び出さない
当社AppDelegate
コード:私たちは、この次のように修正することができました
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let branch: Branch = Branch.getInstance()
branch.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: {params, error in
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
let alert = UIAlertController(title: "Branch", message: "\(params as? [String: AnyObject])", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.window?.rootViewController?.present(alert, animated: false, completion: nil)
})
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
// TODO: ... insert custom logic here ...
print("params: %@", params as? [String: AnyObject] ?? {})
}
})
...
// facebook SDK login integration
return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
// pass the url to the handle deep link call
let branchHandled = Branch.getInstance().application(application,
open: url,
sourceApplication: sourceApplication,
annotation: annotation)
return branchHandled
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
// pass the url to the handle deep link call
let branchHandled = Branch.getInstance().application(app,
open: url,
options: options)
return branchHandled
}
ありがとう、ミラノ。私は支店を使っているメインプロジェクトを調べていました。 – Glenn