Phone Number Auto Spacing like AddressBook on iPhone - ios

I want to be able to replicate what the AddressBook does in Contacts app and Phone app when entering a phone number in both the keypad on the Phone app and adding a contact.
I know I could do it checking each time a character is entered into the UITextField but there are hundreds of number formats out there and it would take me forever to code it all.
Is there any API to this I can use or any known open source code I could use at all?

The UIPhoneFormats.plist contains predefined phone formats for each locale. You'll need to write code to subsitute your input string into these string masks. I had to do something similar, and I shared the results I got here: http://the-lost-beauty.blogspot.com/2010/01/locale-sensitive-phone-number.html

You hit the nail on the head - check the characters typed each time.

Related

Is autofilling with sms code on iOS possible?

Is autofill sms code on iOS possible?
Hello, I am doing a research about autofilling fields with code received via sms.
With flutter package for android it works - when sms comes fields on screen automatically fill with it.
Fot iOS I see the code shows above the keyboard.
Is it possible to make it fill fields just like on android? Without need to show keyborad and press the code from it?
SMS autofill on iOS is done by iOS. Apps aren't involved. They can't see an incoming SMS and they don't see the code shown above the keyboard. It's not "autofill" in that it doesn't automatically type the number. The user must confirm it by tapping the code.
Most of the time, ios judges the best-suited number out of the sms, which it thinks is an OTP, and it's correct. Sometimes it fails, usually with money transaction via credit card, or if the OTP is not six digit.

How to get the user input using textfield from Apple watch

I want to design a password screen for my Apple Watch app. UITextField is not supported by WKInterface. How do I design such a screen? Are any APIs or customizations available?
There really isn't a good way to input a password from apple watch. Apple doesn't want you to do this, so even if you find a way to do it, I would bet apple would reject your app. Also take into account that the apple watch locks every time it is removed from your wrist, so you have to type in a password to use your application anyway. However, if you still want to input a password from apple watch, I would suggest building it yourself. Just use the digital crown to flip through the alphabet and add the character to a password string once the user taps it.
You can try to build a calculator like keyboard with groups and buttons.
The closest equivalent to iOS's UITextField is the text input method presented in WatchKit using presentTextInputControllerWithSuggestions:allowedInputMode:completion:
This would seem like a pretty poor way to input a traditional password, given the vagaries of dictation, though you could think about this more flexibly. For instance, what if the required 'password' was to dictate a phrase that included at least three words out of four words that had been pre-set as the passphrase. That would have a fair degree of entropy, but account reasonably for the likelihood that at times one of the dictated words might be mis-recognised by the API.

SmsMessage length calculator for iOS

In Android there is a great method SmsMessage.calculateLength you can give a string to it and it will detect its encoding and return an array where you can find how many characters are left for 1 sms message, or how many sms messages are there in the string...
I wonder if there is such a method in iOS? Sorry if the question is too simple, I am not a iOS guy.
No. The way you send a text message on iOS is by using the MFMessageViewController class, which presents its own UI, kind of like an activity on Android. It also shows the length of the message for you.
As there is no way to send a text message without using this pre-built iOS component, something like what you're asking for does not exist.

Making a faux iPhone dialer

I want to make a joke application for a friend (not for general sale) that looks exactly like the iOS Phone application but so that whatever number is dialled into the application it appears to dial that number but actually dials a preset number in the background.
The way I figured to do it would be through the following:
User enters a number and hits the call button
Save the number entered as a contact's name and programmatically set the number of that contact as the preset number
Get the application to ring the preset number, to which it would switch over to the real iOS phone application and dial, but with it being a saved number in the contacts it will display the name, which is the number entered by the user.
Delete that contact upon re-opening the application as for it to not ask which number to dial the next time.
This is the only way that I can think of pulling this off, but it seems like it will look unconvincing; especially when it switches over to the real Phone application. Can anyone think of a better way? Such as calling from within the application?
I wouldn't usually take junk requests like this but it made me curious as to pull it off best.Thanks
If you are not going to publish this, then there is no reason why you shouldn't use private apis. See this answer (How to directly make a phone call with private API CTCallDial()?)

How to initiate phone call by contact name on iOS?

I know how to add a contact, I know how to initiate a phone call.
What I don't know, if it's possible to initiate a phone call only by contact name.
What I mean: I add a new contact with phone number with pin code, like 123456*9, this is possible as I already did it.
How call can be initiated when you don't add contact number in this?
BTW I found in Apple docs here
To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone application supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone application does not attempt to dial the corresponding phone number. If your application receives URL strings from the user or an unknown source, you should also make sure that any special characters that might not be appropriate in a URL are escaped properly. For native applications, use the stringByAddingPercentEscapesUsingEncoding: method of NSString to escape characters, which returns a properly escaped version of your original string.
and please check if this solution works for you.

Resources