0

Using the new iOS 9 feature - Universal links, from my understanding, is supposed top open my app whenever a specific domain is opened in browser (or other apps?). I have gone through the documentation and through this guide.

However, when the app opens I do not receive the parameter that is meant to help me open the correct page for the user to view....

I would share the code I'm using, but it's quite a big infrastructure and not really a couple of lines of code (server side JSON, plist rows and some IDs on the developer portal).

Anyone encountered it and could give me a hand here, please?

1 Answers1

1

The Branch guide you linked to (full disclosure: I work with the Branch team) unfortunately doesn't cover a rather important step: what to do after your app opens. Which is exactly the issue you're encountering :). But the good news is you've already done the hard part with all the server and entitlement config.

What you need to complete the loop is a continueUserActivity handler in your AppDelegate.m file. This will pass you a webpageURL property containing the actual URL of the Universal Link that opened your app, which you can then parse and use for routing. It'll look something like this:

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
    if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
     NSString *myUrl = [userActivity.webpageURL absoluteString];
        // parse URL string or access query params
    }
    return YES;
}

Also, when testing keep in mind that Universal Links unfortunately don't work everywhere yet:

enter image description here

P.S., gotta ask...since you found the Branch blog already, had you considered using the service to handle the link routing for you? It can definitely help simplify things!

Alex Bauer
  • 13,147
  • 1
  • 27
  • 44
  • This answer was on point, thank you. Yes we have considered it but we prefer leaving the control in our hands. – user3778974 Mar 23 '16 at 12:07
  • @user3778974 definitely understand. Feel free to drop [our support](https://support.branch.io) a note anyway if you run into any issues with redirects. We've dealt with hundreds of edge cases so happy to provide advice even if you're not on the Branch SDK! – Alex Bauer Mar 23 '16 at 23:54