January 20, 2016

    iOS

    Enabling Moovit schemes, checking if app exists & launching app / external link

    To use deeplinks on iOS, first check if the Moovit app is installed on the phone. If it’s installed, use the scheme for deeplinking, and if not, send the user to Moovit’s listing on the App Store. The required schemes & links are as follows:

    Enabling moovit:// Scheme Links in Your App (REQUIRED on iOS 9+)

    You’ll need to whitelist Moovit in your app’s Info.plist file with an LSApplicationQueriesSchemesentry similar to the following. This will authorize calls to canOpenURL to check for deep links with moovit:// scheme.
    <key>LSApplicationQueriesSchemes</key>

    <array>
    <string>moovit</string>
    </array>
    Checking if Moovit exists & launching Moovit / Download link
    To determine if the app exists, and then launch scheme or external link accordingly, use the following call. Underlined are the links to be used – refer to Schemes & Links section for inserting the desired functionality & correct links. In this example, Moovit is opened with “Nearby Lines & Stations” scheme.
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@”moovit://”]]) {
    // Moovit installed – launch app (with parameters)

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @“moovit://nearby?lat=<lat>&lon=<lon>&partner_id=<ID>” ]];

    }
    else {
    // Moovit not installed – send to store (with unique link given to you)

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @“http://app.appsflyer.com/moovit/?pid=<ID>” ]];

    }

    Previous