【问题标题】:Branch.io links Facebook issueBranch.io 链接 Facebook 问题
【发布时间】:2018-10-19 08:56:28
【问题描述】:
我实现了 branch.io 链接,它适用于 WhatsApp 和 Notes,但不适用于 Facebook Messenger 或任何其他具有应用内浏览器的地方。
根据documentation:
要解决此限制,您的链接必须启用深度视图或类似功能,并带有背后有通用链接的号召性用语链接/按钮。这样,单击应用程序源中的链接将打开一个包含您的深度视图页面的网络视图,然后用户可以单击链接/按钮来启动您的应用程序。
例如,Facebook Messenger 应该打开应用内浏览器,并带有我的链接的深度视图,如果用户点击按钮 - 我的应用应该打开,这对我来说很好,但不能这样工作。
在我的情况下,facebook 正在使用我的 deepview 打开应用内浏览器并自动(我没有点击按钮)将我重定向到... AppStore :(。但如果我手动打开我的应用,我会收到回调和应用程序正在将我重定向到正确的位置。
【问题讨论】:
标签:
ios
deep-linking
branch.io
ios-universal-links
【解决方案2】:
我遇到了同样的问题。从 Branch.io SDK 返回的分支对象正在返回一个没有所有参数的对象。
我所做的只是遵循 Branch.io 提供的出色文档
document provided by Branch.io
所以当我在我的应用程序中使用场景时。在我的 sceneDelegate 中调用这些方法解决了这个问题。
import UIKit
import Branch
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
// workaround for SceneDelegate continueUserActivity not getting called on cold start
if let userActivity = connectionOptions.userActivities.first {
BranchScene.shared().scene(scene, continue: userActivity)
}
}
func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
BranchScene.shared().scene(scene, continue: userActivity)
}
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
BranchScene.shared().scene(scene, openURLContexts: URLContexts)
}
}