The Twitch iOS and Android applications can be launched externally. This page serves to document how to do so. For support, visit the Twitch Developer Forums.
You can check if the Twitch app is installed on the device with something along the following lines:
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 isn't installed, prompt the user to install it!
}
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 isn't installed, prompt the user to install it!
}
// 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;
}
}
URLs starting with twitch:// or ttv:// will open up the Twitch app, if it's installed on the device.
twitch://open
Live Stream
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 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
Launch the app and go to the user's following directory (if user is not logged in, goes to the login page):
twitch://following
twitch://login