4

Is there anyway to use an iOS URL Scheme to open the YouTube to a particular user's profile I've tried youtube://user/myusername but that did not seem to work.

Óscar López
  • 232,561
  • 37
  • 312
  • 386
Jas Ahluwalia
  • 183
  • 3
  • 15

4 Answers4

5

To open a Youtube page in Youtube app (if it's installed on the device) you can check whether the device can open the page:

// URL scheme for youtube app
NSString *youtubeURL = @"youtube://www.youtube.com/user/";

// Page name(or channel name)
NSString *youtubePageName = @"YourPageName";

// Check if the device can open in Youtube app or not.
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString: [youtubeURL stringByAppendingString:youtubePageName]]]){
    // Open in Youtube app
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: [youtubeURL stringByAppendingString:youtubePageName]]];
}else{
    // If device cannot open in youtube app, open the page in browser.
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.youtube.com/user/YourPageName"]];
}

This solution worked for me

iOS 9 edit: Target app's URL scheme must be added to info.plist under LSApplicationQueriesSchemeskey.

Here is a related post: iOS 9 not opening Instagram app with URL SCHEME

Community
  • 1
  • 1
buhanserdar
  • 301
  • 3
  • 8
  • I think it would be more helpful for the op and further visitors, when you add some explaination to your intension. – Reporter Sep 24 '14 at 11:00
  • stopped working in iOS9. It opens app, then redirects to safari – Vaibhav Saran Sep 28 '15 at 12:24
  • Hi, sorry for the late answer. In iOS 9 you need to add the URL scheme of the target app that you need to open into your project's plist under LSApplicationQueriesSchemes key. This post can help you I think. http://stackoverflow.com/questions/30987986/ios-9-not-opening-instagram-app-with-url-scheme/30988328#30988328 – buhanserdar Oct 23 '15 at 09:15
1

This forum post's lack of responses indicates there probably isn't a way to do this currently: YouTube iOS URL Scheme for Channels

But you may be able to request that feature on YouTube's iOS app feedback page. And in the meantime, I'd recommend just linking to users' HTML YouTube pages.

Stuart M
  • 11,458
  • 6
  • 45
  • 59
1

No, few weeks ago I was looking for the same, but i didn't found anything. Instead I've opted for use a UIWebView to show the youtube channel or using the openURL: UIApplication's method to open the channel with Safari.

If you want to save some time, you can use the easy-to-implement TSMiniWebBrowser's control at this Github page.

thxou
  • 691
  • 7
  • 20
0

Here is the youtube Channel Url scheme, try to load it in UIWebView and it will works.

http://m.youtube.com/#/user/channel_name for e.g http://m.youtube.com/#/user/whartonmagazine

IHSAN KHAN
  • 97
  • 3