우리는 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