user1710004
user1710004

Reputation: 209

Youtube iPhone URL shemes

How can I launsh my app when there is a YouTube URL opened in Safari? I searched on the Internet very long, but I didn't see a possibility to do this, because it is an http:// link. But the Google YouTube app does this, can anybody tell me how this works?

Thanks

Upvotes: 0

Views: 327

Answers (2)

Dan Hanly
Dan Hanly

Reputation: 7839

The only way to do this, is to create your own URL Scheme, as denoted here - Implementing URL Schemes

You can then detect to modify any YouTube URLs so they fit in with your app's URL Scheme with JavaScript [webView stringByEvaluatingJavascriptFromString:yourJavaScript]

Here's the kicker. You can only modify pages from within your own web-browsing instance - i.e. creating a UIWebView inside your app, but then, your already in your app, which will render this entire exercise pointless.

You can however, use this method to communicate from within a suite of apps that you've built, so you could maintain your URL scheme across a web-browsing one, which will launch apps in your video playing one.

You can't do this with Mobile Safari though.

Sorry I couldn't be more help.

Upvotes: 1

Max
Max

Reputation: 16719

There is no way you can launch your own app with YouTube link in Safari. Unlike Android Intents, iOS has only one way to launch other apps - url schemes. So when you're trying to open YouTube link in Safari it just calls

[[UIApplication sharedApplication] openURL: @"some url scheme"]

Where "some url scheme" is used internally (it is unknown) and only YouTube app can handle it.

Upvotes: 1

Related Questions