Make Safari Browser appear in iPad/iPhone App - iphone

I have an app that I am in the process of writing and I want too have a button on the screen that the user can press to go to a web page in safari. I do not want to use the UIWebView control and make my own browser, I just want the screen to switch to Safari.
Can any give me some tips how to do this?

You should be able to do it with this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"http://www.google.com"]];

Related

While clicking on some links on UIWebview it's automatically connect(go) to the itunes. but cannot get back to the app after clicking a iTunes link

Here we are using UIWebview related application.
while clicking on some links, it's automatically connect(go) to the itunes.
but it's cannot get back to the app after clicking a itunes link (with out clicking on Exit).
My Question is, how can come back to the app after clicking a itunes.
Try this one uiwebview delegate method.
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL* url = [request URL];
if (UIWebViewNavigationTypeLinkClicked == navigationType)
{
[[UIApplication sharedApplication] openURL:url];
return NO;
}
return YES;
}
I usually insert a button next to UIWebView.
Use a new view and insert button in any corner of view and then put your UIWebView, set your uiwebview is not fit to screen so you can push to exit button. When you tap to button than hide your view. ITs usually what i do for such situation, maybe it can help to you
When you click on any link and you now go to at this link of page and if you want to go previous to your application. Generally You can not go Back to your Application because Apple iOS does not provide this types of feature.
I am not sure but It may be possible in JB Device.
you can add custom tool bar at the top of your view and add back button to custom tool bar to come back to your app. Below to custom tool bar add your webview.Hope it will helps you.
If you are loading the webpage with Safri or you are opening iTunes app with custom schema, it is not possible, because you are leaving the app.
But yes you can do this, If you will load that itunes connect link through web view, and there you can place a custom back button to come back to your previous page.
For Example :
UIWebView *webView=[[UIWebView alloc]init];
[self.view addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.xyz.com"]]];

How to move the user to a URL in Safari

I am making an app for a charity and Apple's review guidelines state that all donations must be made outside of the app in Safari, except for SMS donations, which we're not doing anyway. How do I make a button, that when tapped, goes to a specific URL in Safari? Thanks for your help!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"your.website.here"]];
And put it in an IBAction for your button.
There might be a problem connecting to your site try this:
NSURL *url = [NSURLWithString:#"your.website.here"];
if (![[UIApplication sharedApplication] openURL:url])
NSLog(#"%#%#",#"Failed to open url:",[url description]);
They actually have a post on it here:
How can I launch Safari from an iPhone app?
You can use this code in button click event
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"your url"]];
it automatically opens in safari

Restarting iPhone application after [UIApplication sharedApplication] openURL

As title says I'd like to know how to restart my iPhone app after doing this:
[[UIApplication sharedApplication] openURL:[NSURL UrlWithString:#"tel://0123456789"]]
It seems pretty simple as I saw many topics also talking about restoring the very state of the application when openURL is called, but I can't find how to simply restart the app when the calling is finished.
Is it supposed to be the default behavior? As for me, the iPhone opens Favorites after call is finished, I don't know why.
You can't. Starting an app is solely user's responsibility - which I consider a good thing.
check the discussion here: https://devforums.apple.com/message/128046#128046
create a UIWebView to load the phone url like this:
UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
[webview loadRequest:[NSURLRequest requestWithURL:url]];
just use
[[UIApplication sharedApplication] openURL:[NSURL UrlWithString:#"telprompt://0123456789"]]
It will return to the app after call finished
You can't restart an app after a phone call, as your app has terminated and your code is no longer being run.
If you want to restart after the user visits a webpage, you can put a link with a custom scheme in that webpage, and register it with your app. The user can then tap the link to open your app again.

launch browser(safari)inside my app

I have the following code
NSURL *url = [NSURL URLWithString:#"workingUrl"];
[[UIApplication sharedApplication] openURL:url];
which currently loads the url correctly but when the user is done, they have to exit and go back into my app.
How can the browser be loaded from within my app?
Regards
You have to make a little browser yourself. Create a View Controller with a UIWebView and some buttons that tigger it's methods (forward, back, reload, etc).

opening an URL in safari while iPhone button is clicked

I want to add a button to my iPhone application which will open an URL in safari on iPhone when clicked (my application will terminate right?)
Thanks.
Raihan
You need to use - (BOOL)openURL:(NSURL *)url in UIApplication.
UIApplication is a singleton, so your code would look something like this:
NSURL *url;
[[UIApplication sharedApplication] openURL:url];
Your app will close if you are simply opening in Safari.
You can, however, use a WebView control to embed the web browser in your app. This way your app will not terminate.