Opening TestFlight app from another app and deep link to specific app

David T. picture David T. · Oct 31, 2014 · Viewed 14.9k times · Source

How do i find the scheme of another app and deep link to it from my own iOS app?

More specifically, I want to deep link to the Testflight app upon certain conditions (set by my code). I'm assuming the person has Testflight installed, (which might be a bad assumption but we can live with that assumption).

I know that on Android, you can query for apps and send intents to deep link to someone else's app. What would be the equivalent on iOS?

Answer

picciano picture picciano · Oct 6, 2015

There are two things you need to do. First, check to see if TestFlight is installed. Then create a new link to your app.

NSURL *customAppURL = [NSURL URLWithString:@"itms-beta://"];
if ([[UIApplication sharedApplication] canOpenURL:customAppURL]) {

    // TestFlight is installed

    // Special link that includes the app's Apple ID
    customAppURL = [NSURL URLWithString:@"https://beta.itunes.apple.com/v1/app/978489855"]; 
    [[UIApplication sharedApplication] openURL:customAppURL];
}

This special https://beta.itunes.apple.com URL will be opened directly in TestFlight.

Finally, if you are using iOS 9 (or later), you need to make an addition to your Info.plist to get the canOpenURL: method to work.

If your app is linked on or after iOS 9.0, you must declare the URL schemes you want to pass to this method. Do this by using the LSApplicationQueriesSchemes array in your Xcode project’s Info.plist file. For each URL scheme you want your app to use with this method, add it as a string in this array.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>itms-beta</string>
</array>