32

I have a very simple login page (login + password).

My users are french, so their keyboard are French (azerty).

Since iOS 12, when they click on the password textfield, which is secured, the keyboard switches to English (qwerty), even if they do not have this keyboard installed on their devices. Moreover, if they do not have this keyboard installed, they can't switch back to their keyboard.

I found out that if I deactivate Secure Text Entry, the problem does not show up.

I also tried to set isSecureTextEntry programmatically, and the bug shows up.

I am adding two screenshots, one for each text field.

Thank you a lot for your time & help.

enter image description here

enter image description here

Thib L
  • 704
  • 1
  • 8
  • 20
  • 3
    I have this problem too. It"s definitely an iOS 12 bug. Hopefully they fix it soon. – ian Oct 08 '18 at 11:28
  • 1
    Thank you. I absolutely agree, but I can't find any other traces of this problem anywhere else, can you ? – Thib L Oct 08 '18 at 11:43
  • Have you added the French keyboard from your device settings ? – vivekDas Oct 08 '18 at 11:43
  • French keyboard is my default keyboard as my iPhone is french and was initialized this way, so yes, it is installed :) – Thib L Oct 08 '18 at 11:46
  • I currently have the same bug – Julien Kode Oct 30 '18 at 15:46
  • Hello! I have the same issue, but with a weird behavior. I have a secure text field in the login view controller which is in AZERTY for french users and a secure text field in the signup view controller which is in QWERTY also for french users. It is kind of strange. – IMACODE Nov 19 '18 at 14:10
  • 1
    @imacode yes ! that's exactly my problem too. I have filled a bug report to Apple 45 days ago through Bug Reporter, no news at this point. – Thib L Nov 20 '18 at 15:03
  • Solution here : https://stackoverflow.com/questions/53004048/password-fields-keyboard-switches-from-azerty-to-qwerty-sometimes-only-on-ios/54749897#54749897 – Quentin Rth Feb 21 '19 at 12:54
  • @ThibL Any solution for this issue? – Rajesh Maurya Jun 06 '20 at 08:20

11 Answers11

14

I have the same issue, in my case this bug appears only with a register screen.

The reason is that Apple checks the name of the class/func/parameter to determine (with heuristics) if it is a login/register screen and activate automatically autofill password. By replacing "register" with "Patate" in my code, the problem is solved.

I reproduce this issue with a sample app with 2 textfields (with a security text entry) and a view controller named "RegisterViewController". With a "PatateViewController", I have not the issue.

Moreover, I have this error in console : [AutoFill] Cannot show Automatic Strong Passwords for app bundleID: *** due to error: iCloud Keychain is disabled

Source : https://developer.apple.com/documentation/security/password_autofill

Hope you will find a better way than renaming your code.

Nico
  • 513
  • 7
  • 13
9

I had the same problem appear recently on our application. The problem is linked to the new feature of the PasswordAutofill from Apple.

To bypass this problem you can apply this little piece of code on your secure textfield

    if #available(iOS 12.0, *) {
        tfPassword.textContentType = .oneTimeCode
    }

This should resolve this bug. This should also fix this error:

[AutoFill] Cannot show Automatic Strong Passwords for app bundleID: *** due to error: iCloud Keychain is disabled

Ps: You could also add this new feature to your app. This is a link to an article explaining the process on how to implement this new feature Explanation on how to implement password autofill

Hope it helps.

Martin
  • 843
  • 8
  • 17
3

Same solution in Swiftui now :

TextField("placeholder",text: $YourTextBinding)
                        .textContentType(.oneTimeCode)
                        .keyboardType(.default)

just need to add :

                        .textContentType(.oneTimeCode)
                        .keyboardType(.default)

to a TextField or a SecureField.

hope it helps !

theMouk
  • 595
  • 1
  • 7
  • 21
3

I had the same issue in React Native when I set the keyboardType to "numeric-pad". It's a native IOS issue due to default language set in info.plist file.

I found the solution here : https://github.com/facebook/react-native/issues/27972

Delete these 2 lines to unset the default language :

<key>CFBundleDevelopmentRegion</key>
<string>en</string>

You could also just modify <string>en</string> to <string>fr</string> but then you will have the same issue with english users who will have a switch to azerty keyboard :/

2

Had the same problem and solved it by setting all my textFields textContentType property to UITextContentType.oneTimeCode.

Of course, oneTimeCode is now useless since it's everywhere...

  • I am facing this issue...https://stackoverflow.com/questions/61495065/how-to-enable-disable-onetimecode-feature-for-specific-text-field – Gaurav Borole Jul 07 '20 at 09:21
1

Swift 3:

Create base class for UITextField with languageCode and textInputMode.

class BaseTextField: UITextField {

// ru, en, ....
var languageCode: String? {

    didSet{

        if self.isFirstResponder{

            self.resignFirstResponder();
            self.becomeFirstResponder();
        }
    }
}

override var textInputMode: UITextInputMode? {

    if let language_code = self.languageCode {

        for keyboard in UITextInputMode.activeInputModes {

            if let language = keyboard.primaryLanguage {

                let locale = Locale.init(identifier: language);
                if locale.languageCode == language_code {

                    return keyboard;
                }
            }
        }
    }

    return super.textInputMode;
}}

Usage:

Set your value (ru, en, ...) to languageCode. It will force change the locale in the keyboard.

private func textConfigure(textField: UITextField) {

    textField.keyboardType = .default
    textField.autocapitalizationType = .words
    textField.languageCode = "ru"
}

Hope help you.

kurlyk
  • 11
  • 2
1

iOS 12.1 fixed the problem for me.

You also have to set the parameter textContentType of the password textfield to .oneTimeCode

ndelanou
  • 523
  • 5
  • 16
1

The lamer a bug is, the lamer the solution should be, i mean what a lame work by Apple.

My solution was to force a focus on the password field and then focus on the first field, in my case it was the usernameField.

- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.passwordTextField becomeFirstResponder];
    [self.usernameTextField becomeFirstResponder];
}
TheFuquan
  • 1,737
  • 16
  • 18
0

This was truly an iOS bug => corrected in iOS 12.1

Thib L
  • 704
  • 1
  • 8
  • 20
0

Just in case, I corrected this by simply adding this to my main viewController :

func passwordSignUpViewController(forAuthUI authUI: FUIAuth, email: String, requireDisplayName: Bool) -> FUIPasswordSignUpViewController {
    return CustomPasswordSignUpViewController(authUI: authUI, email: email, requireDisplayName: true)
}

And I created the subclass of FUIPasswordSignUpViewController

import Foundation
import FirebaseUI

class CustomPasswordSignUpViewController : FUIPasswordSignUpViewController, UITextFieldDelegate {

 override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?, authUI: FUIAuth, email: String?, requireDisplayName: Bool) {
    super.init(nibName: "FUIPasswordSignUpViewController", bundle: nibBundleOrNil, authUI: authUI, email: email, requireDisplayName: requireDisplayName)        
 }

 required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
 }

 override func viewDidLoad() {
    super.viewDidLoad()
 }

 func textFieldDidBeginEditing(_ textField: UITextField) {
    if #available(iOS 12.0, *) {
        textField.textContentType = .oneTimeCode
    }
 }
}
0

In my case, following line solve my problem.

textField.textContentType = .newPassword

Jerome
  • 2,114
  • 24
  • 24