Open a URL from iPhone Application - iphone

I want to integrate some links on my iPhone application.
That is when the user touches on the button saying "Yahoo" then Yahoo's page will be opened and then all the functionalities of Yahoo mail has proceeds. How can I do that? I have a bit of idea about NSURL, but not much.
Please help me for that.
Thanks in advance..

To open the page in Mobile Safari, you need to implement something like the following:
NSURL *url = [NSUR URLWithString:#"http://www.google.com"];
[[UIApplication sharedApplication] openURL:url];
You could return to your application using Custom URL Schemes (for more information see the iPhone Application Programming Guide), but since you want to access sites over which you have no control, I presume that isn't an option? Could you use a UIWebView control within your app instead?

In the action method of the target put something like:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"http://www.google.com"]];

Related

Open a shared link in facebook to open in native app if installled in iphone

I am struggling with one thing. Below is the scenario:
I have a website which has a feature to share a link with facebook.
What I want is if someone has the facebook app installed in the iPhone and clicks on the link, it should open it in the app to which that link belongs, if that app is installed.
Could you help me? How can I achieve this ?
You need the URL scheme, which can be found here
Facebook iOS URL Scheme
You will need to open the URL like so
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.some URL.com"]];
You can check and open some specifics applications using url which they are shared their url scheme here.
For example with facebook, you can check if the user has the app installed :
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"fb://profile"]];
And call this method to open the application :
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"fb://profile"]];

how to show facebook Events in application

i want to show users event page in my app
i tried with graph api but not helps.
I want something like This
Got Answer:
i did:
NSURL *url=[NSURL URLWithString:#"https://www.facebook.com/events/list"];
[[UIApplication sharedApplication] openURL:url];
its done
Thanks to all who tried to help me.
this will shows users events who had loggedin - in device

How to return to app after openURL

in my app I need to open a url by using
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"urlstring"]];
after a certain process in the page how can i return to the app.(like facebook doing for safari authentication)
You can't unless you also build the website part, then you can open your own app by calling the App custom URL scheme, wich you will have to add your self to info.plist.
What the Facebook app does is it registers fb:// URLs to redirect to it. Then it sends you to a special link at facebook.com that redirects to an fb:// link while passing some information along (a token or whatever). If you open Safari and type "fb://" into the URL bar you'll get sent to the Facebook app. rckoenes' answer shows how to register URLs to do that, but the part about returning to your app is up to your website (you have to write that redirect page).
This might work?
UIWebView webView = [[UIWebView alloc] init];
NSURL *url = [NSURL URLWithString:#"urlstring"];
[webView loadRequest:[NSURLRequest requestWithURL:url]];

Force a link to open in Safari instead of the in-app browser

I have an issue with QR Readers.
I encode a URL within a QR Code. When read by many iPhone App they will open the URL within a WebView within the app.
I want to open a vcard there which those internal things just wont do - page stays blank whilst when opened directly in safari everything works great.
So my question is:
Is there any way to get out of the WebView and open the safari?
Regards
Nik
No, there is no way to do this, you are at the mercy of the app creators.
NSURL *url = [NSURL URLWithString:#"http://www.google.com"];
if (![[UIApplication sharedApplication] openURL:url])
NSLog(#"%#%#",#"Failed to open url:",[url description]);
While I agree with #rjstelling... try QRafter by Kerem Erkan - you can choose to open the URL specified in a QR code with either the application's web browser or in Safari.

is it possible to open the safari browser from my application instead of using a UIWebview component

Does anyone know if it's possible to open the safari browser with a static link , instead of using a UIWebview component.
If so how can i realize this.
OpenURL can open many things, http and https are registered with safari.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://stackoverflow.com"]];