Post-install Deeplinking Guide on
iOS

Post-install Deeplinking Guide

This guide will enable you to support Button's Mobile Web Publishers. In this guide, we'll:

  1. Configure Button Links
  2. Configure Universal Links
  3. Handle Post-install Deeplinks

Configure Button Links

In the Button Dashboard, navigate to "Merchant" > "Apps" & click on the App you want to configure a Button Links domain for. Once on the App details page, click on the "Add a Button Links Domain" button in the "Button Links Domains" section. Simply fill out the details in the popup modal to complete the configuration.


Configure Universal Links

To support Universal Links for the Button domain (to stop any Safari redirecting) add the Button subdomain (yourdomain.bttn.io) to the Associated Domains Capability. Switch Associated Domains on if it's not already and add your domain to the list of domains registered in the format applinks:yourapp.bttn.io.

Web Links


Handle Post-install Deeplinks

In your AppDelegate file, within the didFinishLaunchingWithOptions function, after calling the method to configure the Button Merchant Library, call the method to handle any post-install deeplinks, handlePostInstallURL().

import ButtonMerchant

func application(_ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    // Replace app-xxxxxxxxxxxxxxxx with your App ID from the Button Dashboard https://app.usebutton.com
    ButtonMerchant.configure(applicationId: "<#app-xxxxxxxxxxxxxxxx#>")

    ButtonMerchant.handlePostInstallURL { url, error in

        guard let url = url else {
            // Route user to the url
        }
    }

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

    // Replace app-xxxxxxxxxxxxxxxx with your App ID from the Button Dashboard https://app.usebutton.com
    [ButtonMerchant configureWithApplicationId:@"<#app-xxxxxxxxxxxxxxxx#>"];

    [ButtonMerchant handlePostInstallURL:^(NSURL * _Nullable url, NSError * _Nullable error) {
        if (url) {
            // Route user to the url
        }
    }];

    return YES;
}

Traffic from the App Store can result in users opening your app without any deeplink path or parameters. Button's Deferred Deeplink product closes this gap by recovering the link the user was originally following based on device fingerprinting.

After a fresh install, the user may both have an attributed source, and a destination deep link which needs to be retrieved from the Button API.

This is achieved using a single call in the Merchant library — the Merchant library will ensure that this network call is only performed when it is possible to have a response (e.g. after first open) so you can safely call it as much as is needed.

The Merchant library will automatically store the attribution from the received URL, so there’s no need to pass it back to trackIncomingURL, but you will need to route the user to the url that is returned, if present.