12

I have several branch links that are meant to deeplink into my iOS app and pre-load an image into a UIImageView. They work properly when the app is installed, regardless of whether it's simply in the background or has been terminated. However, they do not work if the app is not already installed. They do properly link to the app store, but once the app is installed the parameters don't seem to flow through correctly.

I say the parameters don't SEEM to flow through, because I can't find a way to test this since I don't think there's any way to simulate a fresh app install via deeplink in Xcode. I know I can build from Xcode to my phone without the app automatically launching, then click the deeplink, but by that point the app is already installed on my phone so it defeats the purpose of the test. If anyone knows of a way to test app installs via deeplink I'd gladly take that information and run with it for a while...

Here's an example of a deep link that should load a graphic into a shirt design:

https://bnc.lt/l/5wGbOak_QW

Does anyone know of any known issues with Branch not sending data correctly post-install?

Edit: Here's what I've got in my appDelegate Branch code now. I can't prove that the url isn't getting set, but HomeViewController isn't downloading the linked image like it does for non-post-install launches. And like I mentioned before, I don't know how to simulate this situation since the Xcode simulator always installs first so I have no opportunity to simulate clicking the link pre-install.

let branch: Branch = Branch.getInstance()
    branch.initSessionWithLaunchOptions(launchOptions, andRegisterDeepLinkHandler: { params, error in
  if (error == nil) {
    if let url = params["product_picture_url"] as? String {
      let url = NSURL(string: url)!
      HomeViewController.injectedImageUrl = url
    }
  }      
})
othomas
  • 256
  • 2
  • 10
  • I'm using the standard Branch code in my appDelegate, but I can't test to see if the params are getting passed through because I don't know of any way to simulate a Branch link click before the app is installed... So I don't know if the params are getting to/through the branch code or not, all I know is the app isn't behaving as if they are populated. I'll update the post above to include the code I've got in the appDelegate – othomas Jun 29 '15 at 20:57

2 Answers2

13

Can you confirm that you're clicking the link prior to installing the app? Here's the test flow to cause the parameters to be passed through a fresh install:

  1. Uninstall the app
  2. Paste the link into Safari, then click it. If you're on a simulator, you'll see an error message as it's trying to open up the App Store which isn't installed.
  3. Run the test app from Xcode
  4. Parameters should definitely be passed into init

If that doesn't work, here are some other troubleshooting suggestions:

  1. Can you add logging to make sure that you've added initSession to the right delegate method which executes on first open. It should be in this delegate method:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    
  2. Another common scenario is that the link could be created using the Test key, and you've got the Live key in your plist. Branch doesn't allow deep linking across from Test -> Live or visa versa. If you are unsure which key the link is associated with, you can append ?debug=true to the link (like https://bnc.lt/l/5wGbOak_QW?debug=true) after you've selected Test or Live on the dashboard to see the details. If you've selected the wrong key, it will say 'Link not found'. Otherwise, it will show the details of the links.

Alex Austin
  • 1,142
  • 8
  • 11
  • 1
    Brilliant! I hadn't thought about clicking the link without the app installed, then loading from Xcode to simulate a post-click fresh install. I was able to test with this and realized that my default viewController was being launched from the storyboard before the branch service responded with it's parameters. At which point the branch code was running, but my view was not updating to reflect the changes. Thanks for the assistance! – othomas Jul 01 '15 at 22:56
  • 2
    I was struggling to get installs tracked and found this post. I realized you need a fresh device for EVERY install. Because branch can't track uninstalls, it assumes the user already had the app on every subsequent install after the first, so it tracks it just as an "Open". The key for me was to click Simulator -> Reset Content And Settings. This effectively generates a fresh device. Then click the link you're trying to test in the simulator. Then run your app from Xcode. This reproduces installs 100%. – Sean Oct 07 '15 at 00:41
  • Great! Solved it. Test < - > Live was the problem, but `debug=true` is so good to know! Glad I made the mistake and found this piece of gold here – hashier Aug 04 '16 at 17:36
1

I shot myself in the foot by changing the signature of one of the callbacks in AppDelegate.

I had

func application(_: UIApplication, continue userActivity: NSUserActivity, _: @escaping ([Any]?) -> Void) -> Bool

while the correct signature was

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool

As a result, I would always get ["+clicked_branch_link": 0, "+is_first_session": 0] in the deep link handler, while on the first start after installing the app data would be available as expected. And not a single peep from Branch SDK about missing callback ¯\_(ツ)_/¯ Interestingly, there was a warning from Google Login SDK in the log.

Andrii Chernenko
  • 9,873
  • 7
  • 71
  • 89