call safari in iphone program - iphone

i am working on an application in which i needs to call safari when i click on a button.....
please tell me how to do this
should i create a new view for this ?
kindly help....
please also tell about importing messagebox and callmanager if possible.....
(not talking about sending msg or call from my app ...know that is not possible... i want to call inbuilt applications only) .
also wanto confirm that will my app close when i will call these inbuilt applications....
thanks....

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://9016098909891"]];
You can use the above function to call from the iphone
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.google.com"]];
USe this to open safari and so on.. hope yo got the idea what exactly to do....
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"sms://9016098909891"]];
uSe the above to send SMS from iphone
hAPPY cODING....

If you call openURL with a general (for example not a youtube link) web page, then by default it will be opened through safari. However, your app will be terminated.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.yahoo.com"]];
Sorry, can't help about the messagebox.

Related

Opening an Native ios App inside an Another App?

i have this idiotic Question .
Is there any way open an another ios Application inside a view controller of a app.
I know we can open a another Ios app if we have url schema and the calling application goes to background and called application goes to background.
Is there any way ?? i just got a dream ,so am asking can we do it??
It is not possible to do it with the iPhone SDK. You can do this though by using Private APIs.
You can make it work on jailbroken devices.
But if you want to call native social apps like facebook or twitter you should use this code.
It works and apple approves it.
NSURL *fbNativeAppURL = [NSURL URLWithString:#"fb://"];
if ( [[UIApplication sharedApplication] canOpenURL:fbNativeAppURL])
{
[[UIApplication sharedApplication] openURL:fbNativeAppURL];
}
or
NSURL *twNativeAppURL = [NSURL URLWithString:#"twitter://"];
if ( [[UIApplication sharedApplication] canOpenURL:twNativeAppURL])
{
[[UIApplication sharedApplication] openURL:twNativeAppURL];
}

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

after call end, relaunch the previous app in iphone

I can make a call from my app by use this APIs.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:XXXXXX"]];
I would like to return to my app where I left after the users ends the call. Is that possible?
Try this:
UIWebView *callingWebview;
[callingWebview loadRequest:[NSURLRequest requestWithURL:]];
no it's not possible

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.

iPhone SDK Quitting

I have found many apps where you can press a button or something similar and the application will terminate and bring you back to the home screen. How would I do this?
exit(0);
this can exit the app .
again, the best way I think will be like as follows:
//#step invoke the normal routine applicationWillTerminate
if ([[UIApplication sharedApplication].delegate respondsToSelector:#selector(applicationWillTerminate:)])
{
[[UIApplication sharedApplication].delegate performSelector:#selector(applicationWillTerminate:) withObject:[UIApplication sharedApplication]];
}
//#step force quite app
kill(getpid(), SIGINT);
I got it from other post on the overflow :D
from http://www.iphonedevsdk.com/forum/iphone-sdk-development/6928-exit-application.html
[[UIApplication sharedApplication] terminateWithSuccess];