【问题标题】:Branch Universal Link not working分支通用链接不起作用
【发布时间】:2016-12-05 19:11:08
【问题描述】:

我正在使用 Branch.io 在我的应用程序中实现通用链接。每次我将通用链接(从我的应用程序)复制并粘贴到 Notes 时,我都会单击“打开(应用程序)”,它会将我重定向到错误的视图控制器。它将我引导到用户第一次打开应用程序时看到的主视图控制器。我的 AppDelegate.m 文件中的深层链接路由一定有问题:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

Branch *branch = [Branch getInstance];

WebDeepLinkViewController *WebDeepLinkViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
[branch registerDeepLinkController:WebDeepLinkViewController forKey:@"Article"];

【问题讨论】:

    标签: ios deep-linking branch.io ios-universal-links


    【解决方案1】:

    来自 Branch.io 的 Alex 在这里:

    您似乎正在呼叫instantiateInitialViewController。顾名思义,this loads the main view controller that the user sees when they first open the app。你要instantiateViewControllerWithIdentifier

    另外,你可能会遗漏一行,除非你只是没有将它包含在 sn-p 中:

    [branch initSessionWithLaunchOptions:launchOptions automaticallyDisplayDeepLinkController:YES];
    

    修正后的版本如下所示:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    Branch *branch = [Branch getInstance];
    
    WebDeepLinkViewController *WebDeepLinkViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"DeepLinkingController"];
    
    [branch registerDeepLinkController:WebDeepLinkViewController forKey:@"Article"];
    [branch initSessionWithLaunchOptions:launchOptions automaticallyDisplayDeepLinkController:YES];
    

    DeepLinkingController是Storyboard ID,如果不知道怎么设置,可以找说明here

    【讨论】:

    • 好的,在我更正代码后,我测试了它&通用链接将我发送到应用程序,接受整个屏幕变白。当我添加[branch initSessionWithLaunchOptions:launchOptions automaticallyDisplayDeepLinkController:YES]; 时,应用程序的视图控制器似乎变成了完全白色。可能有什么问题?
    • 很难说...你能分享你完整的 AppDelegate 和视图控制器代码吗?如果您不想在此处发布,请随时 submit a ticket 分支集成团队
    • 发现了问题。使用更正后的代码,Universal Link 将我带到了正确的视图控制器。但是,缺少视图控制器元素,其中包括一个按钮和一个自定义 Web 视图。唯一正确的元素是图像和标签。如何保留这些元素?
    • 我假设它在 BranchUniversalObject 'addMetadataKey' 下不太确定。
    • 很难说。你能包括以前要求的项目吗?这会有所帮助
    猜你喜欢
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 2014-12-09
    • 2016-01-28
    • 1970-01-01
    相关资源
    最近更新 更多