简体   繁体   English

React Native - secureTextEntry 禁用 IOS 13+ 强密码行为

[英]React Native - secureTextEntry Disable IOS 13+ Strong Password behavior

I have an create account form in my app and now on iOS devices running 13+ I'm having an issue where if the the user presses the "done" key while entering a password the normal secure password dots are replaced with the following (see below).我的应用程序中有一个创建帐户表单,现在在运行 13+ 的 iOS 设备上我遇到了一个问题,如果用户在输入密码时按下“完成”键,正常的安全密码点将替换为以下内容(请参阅以下)。 How to disable this behavior so it continues to work as it did on older devices?如何禁用此行为以使其像在旧设备上一样继续工作?

在此处输入图片说明

尝试以下道具:

textContentType={'oneTimeCode'}

Not a optimal solution, but adding blurOnSubmit, and a keyboard Dismiss on submit seems to get the desired behavior back:不是最佳解决方案,但添加 blurOnSubmit 和键盘 Dismiss on submit 似乎可以恢复所需的行为:

import { Keyboard } from 'react-native'

<TextInput
   ...
   blurOnSubmit={false}
   onSubmitEditing={()=> Keyboard.dismiss()}
/>

This problem occurs only if I use two TextInput components with secureTextEntry set to true .仅当我使用两个TextInput组件并将secureTextEntry设置为true时才会出现此问题。

If you don't need that, you might want to get rid of the second TextInput component.如果您不需要它,您可能想要摆脱第二个TextInput组件。

You can also hack around with the value of secureTextEntry , eg setting it only to true when onFocus event was triggered and evolve it from there.您还可以使用secureTextEntry的值进行secureTextEntry ,例如仅在onFocus事件时将其设置为true并从那里演变它。 (see: https://github.com/facebook/react-native/issues/27586#issuecomment-580739397 ) (见: https : //github.com/facebook/react-native/issues/27586#issuecomment-580739397

我遇到了同样的问题,将textContentType="oneTimeCode"添加到屏幕上的所有 TextInput 帮助解决了这个问题。

The best solution so far is to disable the simulator strong password feature.迄今为止最好的解决方案是禁用模拟器强密码功能。

Go to:去:

  1. Settings设置
  2. Passwords密码
  3. It will ask for a password!它会要求输入密码! Type anything and tap on Done.输入任何内容并点击完成。
  4. Turn On AutoFill Passwords and turn it Off again.打开AutoFill Passwords并再次将其关闭。

Source: Strong password autofill appears in iOS simulator来源: iOS 模拟器中出现强密码自动填充

You should use the textContentType prop您应该使用textContentType道具

textContentType="none" If you want to disable all the autofill feature. textContentType="none"如果要禁用所有自动填充功能。

Quote from RN 0.64 docs引自 RN 0.64 文档

Give the keyboard and the system information about the expected semantic meaning for the content that users enter.为键盘和系统提供有关用户输入内容的预期语义的信息。

For iOS 11+ you can set textContentType to username or password to enable autofill of login details from the device keychain.对于 iOS 11+,您可以将 textContentType 设置为用户名或密码,以启用从设备钥匙串自动填充登录详细信息。

For iOS 12+ newPassword can be used to indicate a new password input the user may want to save in the keychain, and oneTimeCode can be used to indicate that a field can be autofilled by a code arriving in an SMS.对于 iOS 12+,newPassword 可用于指示用户可能希望保存在钥匙串中的新密码输入,而 oneTimeCode 可用于指示可通过短信中的代码自动填充字段。

To disable autofill, set textContentType to none.要禁用自动填充,请将 textContentType 设置为 none。

You should use the prop properly or else it will cause improper behaviours on users device.您应该正确使用该道具,否则会导致用户设备出现不当行为。

https://reactnative.dev/docs/textinput#textcontenttype https://reactnative.dev/docs/textinput#textcontenttype

Despite all the hacks and fixes I've seen this is the only one the fully fixed the problem.尽管我看到了所有的黑客和修复,但这是唯一完全解决问题的方法。 https://github.com/facebook/react-native/issues/21911#issuecomment-833144889 https://github.com/facebook/react-native/issues/21911#issuecomment-833144889

<TextInput secureTextEntry={true}/> // input1
<TextInput style={{height: 0.1}}/> // a dummy that jammed in between two secure texts
<TextInput secureTextEntry={true}/> // input2

just add只需添加

autoCorrect={false}

solved for me为我解决了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM