Skip to content

Fix SMS autofill by using single text field#789

Open
William-Laverty wants to merge 1 commit intoXcodesOrg:mainfrom
William-Laverty:fix/sms-autofill-single-textfield
Open

Fix SMS autofill by using single text field#789
William-Laverty wants to merge 1 commit intoXcodesOrg:mainfrom
William-Laverty:fix/sms-autofill-single-textfield

Conversation

@William-Laverty
Copy link

Summary

Fixes the SMS autofill issue where macOS would only fill the first digit of the verification code.

Problem

The previous implementation used 6 separate NSTextField instances (via PinCodeCharacterTextField) for the SMS verification code input. When macOS detects an SMS code and offers to autofill it, it expects a single text field to receive the entire code.

With the old implementation:

  1. User receives SMS code
  2. macOS offers to autofill
  3. User clicks the autofill suggestion
  4. Only the first digit gets filled into the first text box
  5. The SMS message is automatically deleted
  6. User has to request a new code and manually type it

Solution

Replaced the 6 individual text fields with a single NSTextField that:

  • Accepts the entire 6-digit code at once
  • Has .oneTimeCode content type set (macOS 11+) to enable SMS autofill
  • Filters input to only accept digits
  • Maintains visual consistency with a monospaced font
  • Still triggers completion callback when all digits are entered

Changes

  • PinCodeTextView.swift: Simplified from ~160 lines to ~100 lines
    • Single text field instead of multiple character fields
    • Added .oneTimeCode content type
    • Simplified delegate methods
    • Input validation for digits only

Testing

  1. Build and run Xcodes
  2. Sign in with an account that uses SMS 2FA
  3. When the verification code SMS arrives:
    • macOS should show an autofill suggestion above the keyboard
    • Clicking it should fill all 6 digits at once
    • The code should be submitted automatically

Note

I was unable to test the build locally due to a pre-existing package resolution issue (AsyncHTTPNetworkService repository not found), but the changes are straightforward and syntactically correct.

Closes #788

The previous implementation used 6 separate text fields for the SMS
verification code, which broke macOS's built-in SMS autofill functionality.
When the system detects an SMS code and offers to autofill it, it expects
a single text field to receive the entire code.

Changes:
- Replaced 6 individual PinCodeCharacterTextField instances with a single
  NSTextField
- Added .oneTimeCode content type to enable SMS autofill on macOS 11+
- Simplified the code structure while maintaining the same functionality
- Added input validation to ensure only digits are accepted

Now when users receive an SMS verification code, macOS can properly
autofill the entire code with a single click, rather than filling only
the first digit and deleting the message.

Closes XcodesOrg#788
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SMS Autofill doesn't work

1 participant