0
votes

I am using Branch.io to implement Universal Links in my app. Every time I copy and paste a Universal Link (from my app) to Notes I click on 'OPEN IN (APP)' and it redirects me to the wrong view controller. It directs me to the the main view controller that the user sees when they first open the app. Something must be wrong with my Deep Link Routing in my AppDelegate.m file:

- (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"];
1

1 Answers

0
votes

Alex from Branch.io here:

It looks like you are calling instantiateInitialViewController. As its name implies, this loads the main view controller that the user sees when they first open the app. You want instantiateViewControllerWithIdentifier

Also, you might be missing a line, unless you simply didn't include it in the snippet:

[branch initSessionWithLaunchOptions:launchOptions automaticallyDisplayDeepLinkController:YES];

The corrected version would look like this:

- (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 is the Storyboard ID. If you don't know how to set this, you can find instructions here)