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
Related
Can I know the code for facebook application? for example https://www.facebook.com/nike/?fref=ts .. I tried it bit it didn't work. I tried it with the youtube code but it didn't work!
For example for youtube
-(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];
}
}
Does anyone know?
If you see the log in console it will show below log :
-canOpenURL: failed for URL: "youtube://user/toyotaleasing" - error: "This app is not allowed to query for scheme youtube"
The solution is, you need to "whitelist" all your URL schemes which will be used in your app, list down in info.plist.
info.plist key for this is "LSApplicationQueriesSchemes".
This is how your info.plist look like when you add "youtube" as scheme.
Now it will work.
I am looking to link my iOS app to my website. I want the link to open the safari web browser. Currently the link goes to the website but stays in the app.
Here is what I am using:
<a onclick="window.location.href='http://www.website.com/folder/page.php';">Contact</a>
Any suggestions?
To open a webpage in device's browse, use following code
NSURL *strURL = [[NSURL alloc] initWithString:#"http://www.website.com/folder/page.php"];
if ([[UIApplication sharedApplication] canOpenURL:strURL]) {
[[UIApplication sharedApplication] openURL:strURL];
} else {
NSLog(#"Cann't open url : %#",strURL);
}
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 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.