I am using youtube app in my app but when I open it in iPhone5 ios7.1.1, then it does not open my youtube channel and instead it opens youtube home page.
So, how to redirect it my youtube channel. Actually this reflect youtube version.
NSURL *youtubeURL = [NSURL URLWithString:#"youtube://user/UCdCsY57HeAs1gb575scqA"];
if ([[UIApplication sharedApplication] canOpenURL:youtubeURL]) {
[[UIApplication sharedApplication] openURL:youtubeURL];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.youtube.com/channel/UCdCsY57ZfHeAs1gb575scqA"]];
}
Please help.
Related
I have an iOS application and I have a link https://vimeo.com/33881529
When I click it and while having a Vimeo application on my iPhone, it opens it in the browser. I don't want that. I want the video to run from my application to vimeo application.
Edit:
- (IBAction)film:(id)sender {
NSURL *linkToAppURL = [NSURL URLWithString:#"vimeo://33881529"];
NSURL *linkToWebURL = [NSURL URLWithString:#"https://vimeo.com/33881529"];
if ([[UIApplication sharedApplication] canOpenURL:linkToAppURL]) {
[[UIApplication sharedApplication] openURL:linkToAppURL];
} else{
[[UIApplication sharedApplication] openURL:linkToWebURL];
} }
Other EDIT
- (IBAction)vimeofilm:(id)sender {
NSURL * vimeoURL = [NSURL URLWithString:#"vimeo://33881529"];
if ([[UIApplication sharedApplication] canOpenURL:vimeoURL]) {
//do stuff
}
else{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://vimeo.com/33881529"]];
}
}
I think the main question is about playing the video within your application. There are two possibilities that I can see here:
You load the URL within a WebView in your application. Technically, this will play the video within your app.
You create a HTML string with the below iFrame tag:
< iframe src="//player.vimeo.com/video/VIDEO_ID" width="WIDTH" height="HEIGHT" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen>
Replace the VIDEO_ID with your video ID. Once this HTML String is ready, load it into as HTML data in your WebView.
Hope that helps!
You can have the Vimeo application open and play the video with the help of VIMDeeplink. It is an open-sourced helper library supporting both swift and Objective-C. You can use it to check if the Vimeo iOS app is installed, and depending on if it is you can use it to open the Vimeo video player for a specific video; if the Vimeo app is not installed you can use the library to view the listing in the App Store. The ReadMe is pretty thorough and should answer all questions regarding the use of the library.
As i read on Vimeo github page, i found this solution:
doc:
https://github.com/vimeo/VIMDeeplink#swift-and-objc
The Vimeo deeplink base URL is:
vimeo://app.vimeo.com
Open the video player:
let uri = "/videos/33881529"
so your code should be like this:
- (IBAction)film:(id)sender {
NSURL *linkToAppURL = [NSURL URLWithString:#"vimeo://app.vimeo.com/videos/33881529"];
NSURL *linkToWebURL = [NSURL URLWithString:#"https://vimeo.com/33881529"];
if ([[UIApplication sharedApplication] canOpenURL:linkToAppURL]) {
[[UIApplication sharedApplication] openURL:linkToAppURL];
} else{
[[UIApplication sharedApplication] openURL:linkToWebURL];
}
}
i've tried it and it works properly.
Thanks
This question already has answers here:
How can I launch Safari from an iPhone app?
(7 answers)
Closed 7 years ago.
I added a code for Xcode from the internet.
This one:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.youtube.com"]];
It took me to www.youtube.com on the Safari browser, what if I have youtube application? how can it open that from the application in my iPhone?
p.s I’m a newbie
- (IBAction)btnYoutube:(id)sender {
NSURL *linkToAppURL = [NSURL URLWithString:[NSString stringWithFormat:#"youtube://user/%#",#"toyotaleasing"]];
NSURL *linkToWebURL = [NSURL URLWithString:[NSString stringWithFormat:#"http://www.youtube.com/user/%#",#"toyotaleasing"]];
if ([[UIApplication sharedApplication] canOpenURL:linkToAppURL]) {
// Can open the youtube app URL so launch the youTube app with this URL
[[UIApplication sharedApplication] openURL:linkToAppURL];
}
else{
// Can't open the youtube app URL so launch Safari instead
[[UIApplication sharedApplication] openURL:linkToWebURL];
}
}
Use URL scheme for youtube : youtube://
Eg.
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"youtube://www.youtube.com/watch?v=<video-id>"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"youtube://www.youtube.com/watch?v=<video-id>"]];
}
Hope, it'll help you.
Is it possible to force through your application that it will open the web link in safari only not in native app like facebook, twitter or web view etc.
So far i searched found only this code that is used for opening the link
NSURL *url = [NSURL URLWithString:#"www.facebook.com"];
[[UIApplication sharedApplication] openURL:url];
But what can we paste in else there below?
if ([[UIApplication sharedApplication] canOpenURL:nsurl]){
[[UIApplication sharedApplication] openURL:nsurl];
}
else {
//Open the url as usual, but how?
}
Use http://facebook.com/ instead of www.facebook.com
this will force a link to open in Safari instead of native app*
NSURL *myURL = [NSURL URLWithString:#"http://facebook.com/"];
if ([[UIApplication sharedApplication] canOpenURL:myURL]) {
[[UIApplication sharedApplication] openURL:myURL];
}
You can use a webView to open any link of your choice.
I'm working on iOS application. Here is the code i used
NSURL *url = [NSURL URLWithString:#"fb://page/5718758966"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
else
{
//Open the url as usual
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://facebook.com/5718758966"]];
}
As I mentioned, this code has worked to open Facebook app but shows blank page; my question is if there is an alternative link I can use that will both open the app and direct the user to this specific page, or is this simply a Facebook bug?
Thanks!
Instead of "fb://page/5718758966" try "fb://profile/5718758966" for your URL.
I was trying to open the Facebook app with particular Facebook page from my app with the following code:
NSURL *url = [NSURL URLWithString:#"http://www.facebook.com/pagename"];
[[UIApplication sharedApplication] openURL:url];
When I click on the button it opens the Facebook app but the required page doesn't load or show.
Is there any other way to open the Facebook app with particular Facebook page? Please correct me If I am doing something wrong.
Thanks in advance.
To open the facebook app directly you should do the following:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString: #"fb://profile/PAGE_ID"]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"fb://profile/PAGE_ID"]];
}
else
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"http://facebook.com/PAGE_NAME"]];
}
This is a solution including a fallback for web.
To determine your PAGE_ID you could use a service like this.