3

How is Lyft suggesting my phone number in the QuickType bar so that I do not have to enter it manually? I know Apple introduced autofill functionality for usernames, passwords, security codes, and more with iOS 12 and it looks like this phone number suggestion may be using a similar function but I cannot figure out how to get any of my apps to suggest the phone number like Lyft is doing below.

Lyft Enter Phone Number Screenshot

7
  • Is it possible that it's just looking up the devices contacts? Feb 24, 2019 at 22:13
  • There is a property that you set to tell the OS what type of text field it is. Feb 24, 2019 at 22:15
  • @CharlieFish what is the property?
    – Alec
    Feb 24, 2019 at 22:28
  • 4
    Set the text field's textContentType to .telephoneNumber and you get this behavior.
    – Rob
    Feb 24, 2019 at 22:28
  • 2
    Even more cool, if you send SMS messages to validate a phone numbers and set the SMS validation code’s UITextField text content type to .phoneNumber, too, it will automatically pull the verification code from the SMS and presented as an option, too. Really streamlines SMS-based verification workflows.
    – Rob
    Feb 24, 2019 at 22:35

3 Answers 3

4

From Interface Builder / Storyboard

  • Select a textField.
  • Show the Attributes inspector.

Content Type Telephone Number

From Code

You can access this property in any UITextField

textField.textContentType = .telephoneNumber
1
  • 1
    it is not showing the suggestions for keyboardType set to 'phonePad'. Jun 9, 2020 at 6:21
1

As @Rob said in a comment below my question.

textField.textContentType = UITextContentType.telephoneNumber

Results in the behavior I was looking for. Thanks @Rob

2
  • 1
    UITextContentType is redundant textField.textContentType = .telephoneNumber
    – Leo Dabus
    Feb 24, 2019 at 22:59
  • 1
    textField.textContentType = .telephoneNumber Not working in iOS 14.2 Dec 29, 2020 at 16:53
0

Phone number autofill strong solution:

textField.keyboardType = .asciiCapableNumberPad

textField.textContentType = .telephoneNumber

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.