Contents

Mobile Deep Links

Introduction

This guide describes how to launch the Twitch iOS and Android applications externally.

For support, visit the Twitch Developer Forums.

Is the Twitch App Installed?

You can check if the Twitch app is installed on the device as follows.

On iOS Objective C:

NSURL *twitchURL = [NSURL URLWithString:@"twitch://open"];
if ([[UIApplication sharedApplication] canOpenURL:twitchURL]) {
    // The Twitch app is installed, do whatever logic you need, and call -openURL:
} else {
    // The Twitch app is not installed. Prompt the user to install it!
}

On iOS Swift:

let twitchURL = NSURL(string: "twitch://open")
if (UIApplication.sharedApplication().canOpenURL(twitchURL!)) {
    // The Twitch app is installed, do whatever logic you need, and call -openURL:
} else {
    // The Twitch app is not installed. Prompt the user to install it!
}

Note: On iOS, you also must change your app’s Info.plist file, to declare that the app is allowed to query the twitch scheme. See the Apple documentation on this.

On Android:

// Where “packagename” is the package name of the Twitch app:

private boolean isPackageInstalled(String packagename, Context context) {
    PackageManager pm = context.getPackageManager();
    try {
        pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
        return true;
    } catch (NameNotFoundException e) {
        return false;
    }
}

Launching the Twitch App

Android, iOS 10 & Later

The Twitch app supports universal links. If you confirm that the app handles a desired universal link (e.g., https://twitch.tv/smashley goes to Smashley’s channel), you can pass that URL to:

UIApplication.open(_:options:completionHandler:)

along with this option:

[.universalLinksOnly: true]

The option instructs the system to open the URL only if there is an installed app that handles it (e.g., Twitch), as opposed to opening it in Safari.

With universal links, you don’t need to check whether the app is installed. You can just launch a normal web link, and the system checks whether it needs to open the app (if it’s installed) or the browser (if the app isn’t installed).

We recommend the universal-link approach.

iOS 9 & Earlier

If the Twitch app is installed on a device, URLs starting with twitch:// or ttv:// will run the app. These URLs fail if the app is not installed.

To launch the app: twitch://open

To launch the app and
go to a specific …
Use this URL
Channel twitch://stream/<channel name>
– OR –
twitch://open?stream=<channel name>
Game directory twitch://game/<game name>
– OR –
twitch://open?game=<game name>
VOD twitch://video/<video ID>
– OR –
twitch://open?video=<video ID>

For a VOD with this URL:
twitch.tv/some_channel/v/1234567
the video_id is v1234567.
Channel activity feed (includes VODs) twitch://channel/<channel name>
– OR –
twitch://open?channel=<channel name>
User’s following directory twitch://following
If the user is not logged in, this goes to the login page.
Login page twitch://login
Chat room twitch://<channel name>/rooms/<room name>