I know that unlike the operator name and the country code, it's not possible to get the user's phone number in iOS programmatically (at least not with publicly available APIs).
But I have just tried the app Lyft and it is autosuggesting my current phone number. I want to know how this app is doing that.
The phone number suggestion appearing above the keyboard is a built-in iOS feature and it works if a Text Content Type is set for a UITextField.
Since iOS 10, you can provide a content type for your inputs. iOS then will recommend autofill options for the given content type.
You can set up a content type...
in Interface Builder by navigating to the Text Input Traits section of the Attributes inspector (the fourth icon from the right in the top sidebar):
...or programmatically with:
textField.textContentType = .telephoneNumber
Related
I'm implementing an App only for iPad and apparently react native doesn't support numeric keyboard type for iPad. just want to know any idea how to manage keyboard to show only numbers.
I tried some regular expression but it doesn't work properly.
For some reason this is not supported for Ipad. So you will need to either:
1) Show non-numeric characters but only accept numeric characters (via code).
2) Use this library react-native-custom-keyboard.
Try
keyboardType = 'number-pad'
Hope it works
Or read some article
I watched this video What's New in Cocoa Touch at WWDC 2018 and seen:
How to show this information?
Review WWDC 2018 Session 204 - Automatic Strong Passwords and Security Code AutoFill.
You will need to use a UITextField for entry and the system keyboard (no custom controls) and set the textContentType on it to .oneTimeCode (new in iOS 12).
let securityCodeTextField = UITextField()
securityCodeTextField.textContentType = .oneTimeCode
The operating system will detect verification codes from Messages automatically (messages that contain the word "code" or "passcode") with this UITextContentType set.
For those who's searching how to do that in HTML: need to add autocomplete="one-time-code" for your input field.
<input id="single-factor-code-text-field" autocomplete="one-time-code"/>
(from Apple Docs)
However, that will not work in most Android phones. For Android it's more complicated: https://web.dev/sms-otp-form/. You will need to add #domain #code to SMS text and also implement extra JS to pickup the code.
Storyboard
Select UITextField > Show the Attributes inspector > Text Input Traits > Content Type > One Time Code
iOS supports Password AutoFill on UITextField, UITextView, and any custom view that adopts the UITextInput protocol. System keyboard set the textContentType on it to .oneTimeCode
singleFactorCodeTextField.textContentType = .oneTimeCode
Important
tvOS apps can also support Password AutoFill using the same
content-type settings. The AutoFill QuickType bar appears above the
keyboard when entering passwords with an iOS device using the Control
Center keyboard, the Remote app, or the Continuity Keyboard. Focus is
also advanced to the login button when the login fields are populated.
Warning
If you use a custom input view for a security code input text field,
iOS cannot display the necessary AutoFill UI.
if you have a website and you want to use some OTP sms authentication
you should use code: or passcode: before your OTP message.
On iOS, the numeric keyboard has a return key on iPad but not on iPhone.
I am taking the standard approach of adding a toolbar as inputAccessoryView of the target text field, with a "Done" button in it.
However, on iPad the keyboard already has a return key (labelled "Done", "Next", etc. according to one of the constants enumerated in UIReturnKeyType); I would like to display the accessory view only when necessary.
Is there a way to detect the presence of such key, other than the (inelegant) method of querying the user interface idiom?
I ask this because, the fact that the iPad keyboard has a return key and the iPhone one does not seems like an implementation detail, in principle unrelated to whether the device is a phone or a tablet. As such, it feels like it might change in the future, breaking my (unrobust) solution.
I'm worked on a custom keyboard and Apple review team rejected it because the keyboard does not support 'Numbers and Decimals' types.
So, I found that the problem is that when a text field requires those specific type of keyboard (for example to inset age, measures, or other numeric values), my keyboard 'misses to respond'.
I understood, reading from Apple documentation, that you must respond to the UIKeyboardTpye property per text object's.
I searched for specific delegate of the UIInputViewController but I wasn't able to find something close to that.
In this forum I found that one good place to examine the current keyboard type required is the textDidChange: delegate, but, it is not called.
I suppose this responder is called when your keyboard, somehow, 'declares' to iOS that it can handle Numbers or Decimal types. In fact I created a simple app with a simple UITextView that requires the Decimal keyboard type:
textView.keyboardType = UIKeyboardTypeDecimalPad;
And I put a NSLog() in the keyboard extension Input View Controller textDidChange: delegate.
As I tap on the text view my delegate is not called, instead the standard Decimal keypad is shown and in the Xcode console I see the following message:
Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 405786210_Portrait_iPhone-Simple-Pad_Default
I noticed also that this message comes when the UITextView requires the not-allowed keyboard types, i.e. the phonepad. All other keyboard types do not issue that message and the custom keyboard is shown and the textDidChange: delegate is correctly called.
The Numbers and Decimal types are surely allowed and are a MUST for the review team guys. Why the behave as a forbidden-types?
I think we need to 'declare', for example in the info.plist that our extension supports various keyboard types, but... well or more simply... I do not get the point... so... I'm asking... How can I add multiple keyboard types to my keyboard extension??
Thank you very much for help!
After the second rejection of my keyboard extension they sent me a screenshot. I noticed that they, generally, test apps on iPad. This made me think.
After some test it came out that the Numbers and Decimal types do not respond the same way on iPhone and iPad.
On iPhone a text view requiring Numbers or Decimal type keyboard always shows the iOS keypad, i.e. the custom extension is not called.
On the other side, on the iPad a text view requiring Numbers or Decimal type keyboard activates the custom extension.
Finally, after provided a standard numeric keypad (even if my keyboard uses hand-written techniquies) it was approved.
I have a requirement wherein I have to change the text of the return key of the iPad to Sign-in. Obviously it is not one of the options available in the sdk. I have searched it over the net and it seems doing that possible.
The only question remaining is whether the app would be accepted by Apple if I modify the default system keyboard? The HIG is not clear on this , it states that "A custom input view can replace the system-provided onscreen keyboard in apps" and "You can also provide a custom input accessory view, which is a separate view that appears above the keyboard (or your custom input view)". Nothing about whether we are allowed to add an extra button on a system keyboard.
Any experiences??
#Vin you can change the name of return key of the keyboard to your requirement. I have an app that has the changed to return key name to Done and Search. And apple did not reject it.
To "Sign-In" you can use the return key UIReturnKeyJoin
textField.returnKeyType = UIReturnKeyJoin;
EDIT
Nope. You get the return key and
keyboard types defined in the OS.
Unless you want to try to hack the
keyboard's view hierarchy to change
that button, which would be a really
bad plan. (Standard recommendation
here is to file a bug report with
Apple to let them know you'd like
more/different options.)
see Custom iPhone return key text
Since I didn't get any satisfactory answer, I convinced the client that it would be inappropriate to modify the default system keyboard for a sake of one button(even if it is allowed by Apple). We are now going for the "Go" option available for return key.