Restarting iPhone application after [UIApplication sharedApplication] openURL - iphone

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.

Related

How to control unwanted Pop-up that appear when making call within app

I am developing an app about making call and returning to app when calling ended. Here is my code;
**callWebview = [[UIWebView alloc] init];
NSURL *telUrl=[NSURL URLWithString:#"tel:4444484"];
[callWebview loadRequest:[NSURLRequest requestWithURL:telUrl]];**
This is ok but when url request is being sent, A pop up appears on the screen.
This is the screenshot when I press the button and run the code at upside;
So , Here is my question;
Can I block this pop up to appear on the screen ?
If I can't how can I change the message body and buttons of this popup ?
Thanks...
If you do not use the UIWebView the message will not appear, but then you will not be able to come beck to the app.
To make a call with out the alert:
NSURL *telUrl=[NSURL URLWithString:#"tel:4444484"];
// Check if the iOS device support dialing a number
if ( [[UIApplication sharedApplication] canOpenURL:telUrl]) {
[[UIApplication sharedApplication] openURL:telUrl];
}
But there is no solution that will do exactly what you desire, so either it is the dialog or no dialog but not retuning to you app.
Try the following instead:
NSURL *telUrl=[NSURL URLWithString:#"tel:4444484"];
[[UIApplication sharedApplication] openURL:telUrl];

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];
}

Make phone call on iPhone and take user back to app? (UIWebView does it)

I used this code to make phone call:
NSString *phoneNumber = [#"tel://" stringByAppendingString:mymobileNO.titleLabel.text];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
and when the call ends, it does not take user back to the app. However, if I show a website in UIWebView and there is a phone number in the website(ie UIWebView recognises it), and if I tap that phone number link to make phone call, I will be taken back to the app when the call finishes.
My preliminary thinking is that the UIWebView does something internally like a deep link to the Phone app then another deep link inside the deep link to take the user back to the app. But I'm not sure. Is there a way to implement this feature?
Thanks!
You need to use the telprompt URL, not tel.
So:
NSString *phoneNumber = [#"telprompt://" stringByAppendingString:mymobileNO.titleLabel.text];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
This will also give the user a confirmation box before calling the number.
Edit:
This question covers the same issue.
Edit 2:
For those wondering if this URL will result in rejection from the App Store, the answer is generally no. The greater risk is that Apple will suddenly stop supporting the telprompt scheme. As explained by this article, there is a slightly 'safer' way of implementing telprompt with UIWebView (which uses telprompt internally, even if you call it with tel). The relevant code from the article shows how using the documented tel scheme can still give you the effect of telprompt:
+ (void)callWithString:(NSString *)phoneString {
[self callWithURL:[NSURL URLWithString:[NSString
stringWithFormat:#"tel:%#",phoneString]]];
}
+ (void)callWithURL:(NSURL *)url {
static UIWebView *webView = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
webView = [UIWebView new];
});
[webView loadRequest:[NSURLRequest requestWithURL:url]];
}
(Code taken from the article reference in my second edit)
The website: http://www.raizlabs.com/dev/2014/04/getting-the-best-behavior-from-phone-call-requests-using-tel-in-an-ios-app/ has a discussion of whether to use telprompt (undocumented, Apple could potentially change the API without notice), and instead using a category that sends the number to a web view which opens it using telprompt. This has the advantage of not breaking if Apple does something odd.

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

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).