Directly launch phoneNumber dialog on iPad - ios

If I use the UIDataDetectorTypePhoneNumber on a UITextView, and click a phone number on a device that has no phone (e.g. iPad), I get a Send Message / Add to Contacts / Copy popover. Is there some way to bring up that dialog directly in code or would I have to reimplement?
I did try [[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:5555555"]]; but that does not bring up the dialog.
There are some subtle differences between how detected links and buttons behave and my client wants a clickable phone number that behaves like a button.

I did some method swizzling to see where this popover comes from, and it looks like it is generated before the openURL: method in UIApplication.
Digging further, it looks like the popover comes from some private objects in UITextView.
I think you'll have to reimplement.

Did you try it with some forward slashes?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://5555555"]];
Possibly related to this.

Use telprompt://5555555 instead of tel:5555555

Related

Disable remote controls iOS

By default, remote control is activated on my streaming application but under a certain circumstance I want to disable all controllers and show nothing when the screen is locked.
First I tried to set now playing info to nil like this [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo: nil]; and all text, image and progress disappear but the control buttons and volume bar was still showing.
After that I tried this [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; but it gives me nothing, it shows the same thing on the screen as the previous method call.
For the record, I'm calling [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; on AppDelegate before I tried to call any of the previous methods.
So, I have not found anything related to this that could help me with my problem and I would appreciate any help :)

How to get the window back with code after Reachability (double-tap home) triggered on iPhone 6?

Double-tap on iPhone 6's home button will shift the window down to let user can reach the top of the window. Tap into a UITextField(show inputView) or show UIActionSheet can let the window get back.
So is there a line of code can get the window back without showing an extra view?
There seems to be no public way to achieve what you're asking for yet.
Digging a little bit deeper we can find UIApplication's private method called _deactivateReachability made exactly for this problem. You can call it this way:
[[UIApplication sharedApplication] performSelector:NSSelectorFromString(#"_deactivateReachability")];
But keep in mind that this solution will probably get your app rejected during the app review because of the usage of private undocumented API and it's better to wait when Apple will make public API for this feature.
Swift Version of Ilya's answer:
UIApplication.shared.perform(Selector(("_deactivateReachability")))

remove the alert that pops up when calling from iOS app using telprompt://

I need to make a call from my iOS app, and after the user is done calling, i need him to come back on the same app screen from where he made the call. if i use the following code
NSString *phoneNumber = [#"telprompt://" stringByAppendingString:#"999999999"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
i achieve what i want, but get an unwanted alert confirming if the user wants to make a call or not. I don't want this.
If i use the code
NSString *phoneNumber = [#"tel://" stringByAppendingString:#"999999999"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
i do not get the alert, but i do not get back to my app screen too..!!
Is there a way where i do not get the alert while making the call and get back to the app screen after making the call?? please help..
You cannot do otherwise, those are the two possibilities. telprompt with alert and callback or tel with not coming back and no alert.
If the users leaves the app to make a phone call, there's no way you can return to your app after it. Your app is backgrounded, and the phone app is foregrounded.

opening dial pad for calling number user want

i want to open dial pad when user click on call button and then user enter phone number and call it
i know we can make call like this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"telprompt://2135554321"]];
but i want to open dial pad and then let user enter number and press call button to call
if this is not possible then want to do something like my app open direct to dail pad then user call it and then it should redirect to my app
No you cant do this in iOS . iPhone SDK not gives you direct access to dial a numbers from the application .The one way to achieve this is
take a text field
textfield.keyboardType = UIKeyboardTypePhonePad;
and
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel://%#",textfield.text]]];
You have to see the format for entering the number.
Why not create a UIView that has a "UITextField" and when the text field comes up, have the keyboard set to only be numbers (i.e. pretty much the same thing as the dialpad).
And once they are done entering in the number, then you can call the "openURL" line you have above.

How know when app open a URL?

I'm working on an iOS app and looking to see if it is possible to know when a user opens a URL (for example, user press a button and executes code like below)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"telprompt://1234567890"]]
telprompt: show an alert when it's called. But I want a way to detect if user press Ok button or Cancel button. I need execute some code in -(void)applicationDidEnterBackground:(UIApplication *)application depending which button was pressed. Any idea?
You could subclass UIApplication and over-ride openURL:
This will give you control and have you decide what to do.
Make sure to call super implementation though if you want to open the URL
EDIT
Here is an example
How to subclass UIApplication?

Resources