How to make a phone call and return to the original application after that

If I use UIWebView to display the phone number and set the type of data detector to UIDataDetectorTypePhoneNumber, then when I click on its possible number to call.

At the end of the phone call, I will return to my application.

However, if I try to programmatically invoke a phone application using

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:123456789"]]; 

or

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]]; 

Then, after the call is completed, it is impossible to return to my application.

Is it possible to be able to programmatically launch the application for the phone, and then return to my application after the call is completed, just as if the user clicked on the number in UIWebView?

+4
source share
6 answers

Unfortunately, Apple does not allow this to happen, because when you run the openURL command, it will open this application, and since you cannot access anything in this application, you will have to enter your application again yourself. However, you can save your state in NSUserDefaults , and then the user will be able to return to the same part of the application as when he left. Get Help: iOS Human Interface Guides

+1
source

Instead:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]];

using:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://123456789"]];

telprompt:// vs. tel://

A warning appears, and the user will need to press the "call", but after the call is completed, he will return to the application.

+4
source

use for example

 NSString * telNummer; NSString *osVersion = [[UIDevice currentDevice] systemVersion]; if ([osVersion floatValue] >= 5.0) { telNummer = [NSString stringWithFormat: @"telprompt://%@", person.telephoneNumber]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telNummer]]; } else { telNummer = [NSString stringWithFormat: @"tel://%@", person.telephoneNumber]; UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:telNummer]]]; webview.hidden = YES; // Assume we are in a view controller and have access to self.view [self.view addSubview:webview]; [webview release]; } 
+2
source

You can send a local notification 2-3 seconds after the dialing application is visible to the user. it is not perfect, but clicking on a local notification and returning to the original application, it is easier to double-click the home button and switch the application.

+1
source

NSURL * url = [NSURL URLWithString: @ "telprompt: // your phone number"]; [[UAppication sharedApplication] openURL: url];

0
source

Can this work?

 UIWebView webView = [[UIWebView alloc] init]; NSURL *url = [NSURL URLWithString:@"tel:123456789"]; [webView loadRequest:[NSURLRequest requestWithURL:url]]; 
0
source

Source: https://habr.com/ru/post/1403124/


All Articles