Yus*_*ail 14 xcode ios reactjs react-native
I'm on React Native 0.59.9 (latest at the time of this post), and have a login screen in my mobile app that I would like iOS 12's autofill feature to pick up and save the password for a new user. With what I've set up, the app shows the keyboard with the autofill option but never pop's up the 'Save Password' for a new user's credentials.
What the keyboard autofill looks like right now: https://imgur.com/6gVpGbU
In React Native's documentation, they now expose textContentType in the TextInput component. To set it up for iOS 11 autofill, the username textContentType would be set to 'username' and the password textContentType would be set to 'password'.
RN textContentType documentation: https://facebook.github.io/react-native/docs/textinput#textcontenttype
For iOS 12 autofill, which is supposed to introduce the 'Save Password' feature to mobile app's as well now (previously was websites only) the configuration is different for the password.
The password textContentType would be set to 'newPassword' instead. This isn't working though, in fact it seems to be buggy and breaks the app as it suggests username's for the password field with this set...
What I've tried to do to implement iOS 12's autofill feature in React Native:
<TextInput
placeholder={'Enter username'}
autoCapitalize={'none'}
autoCorrect={false}
textContentType={'username'}
/>
<TextInput
placeholder={'Enter password'}
autoCapitalize={'none'}
autoCorrect={false}
secureTextEntry={true}
textContentType={'newPassword'}
/>
Run Code Online (Sandbox Code Playgroud)
In the mobile provision, I've made sure to enable Associated Domains as an entitlement. (Done through Apple Developer website).
In my domain (for example www.mydomain.com), the file apple-app-site-association (with no extension) that has the following has been put into the root directory and is publicly available (https supported).
{
"webcredentials": {
"apps": [
“ZT978FY6AB.com.company.my.app”,
]
}
}
Run Code Online (Sandbox Code Playgroud)
In XCode, I've set up the Associated Domains to point to that domain. Example:
webcredentials:www.mydomain.com
Run Code Online (Sandbox Code Playgroud)
The expected output of implementing this is that iOS pops up the 'Save Password' dialog when a new user enter's their credentials.
What the pop up dialog should look like: https://imgur.com/GH4hfP8
Instead, it never pops up. The user just heads straight into the app upon successful login without the dialog ever appearing for saving the password. This essentially means that none of my users can save their credentials to the password manager of their choice (not even iCloud keychain).
Since this feature does not seem to be testable on a simulator, I've been testing it on an iPhone 7 Plus with iOS 12.3.1 installed and autofill enabled in the settings as can be seen in the below image.
Any ideas what I'm doing wrong, or if I'm missing a step?
Yus*_*ail 32
搞定了!以下是我为使其工作所做的工作。
<TextInput
placeholder={'Enter username'}
autoCapitalize={'none'}
autoCorrect={false}
textContentType={'username'}
/>
<TextInput
placeholder={'Enter password'}
autoCapitalize={'none'}
autoCorrect={false}
secureTextEntry={true}
textContentType={'password'}
/>
Run Code Online (Sandbox Code Playgroud)
webcredentials:www.example.com
Run Code Online (Sandbox Code Playgroud)
不要包含 URL 的 https 部分,也不要包含 /apple-app-site-association 的结尾
https://www.example.com/apple-app-site-association
Run Code Online (Sandbox Code Playgroud)
您也可以在 YouTube URL 和 Amazon URL 上尝试此操作,以查看其 apple-app-site-association 文件为例。
现在我的用户可以使用自动填充登录,最好的部分是 iOS 提供使用触摸 ID、面部 ID 或密码自动填充,具体取决于用户手机的设置。因此,他们可以使用触控 ID 甚至面容 ID 登录,而无需在 RN 应用程序中进行额外工作即可使其正常工作。更好的是,如果他们将其保存到 iCloud,他们可以移动到另一台设备,并且仍然可以根据需要使用相同的凭据登录该应用程序。
我犯了一些错误,希望您可以通过阅读以下内容来避免这些错误。
{
"webcredentials": {
"apps": [
“ZT978FY6AB.com.company.my.app”,
]
}
}
Run Code Online (Sandbox Code Playgroud)
它们不是标准的双引号,这导致 Apple 无法解析文件。如有疑问,请复制 Apple 在其文档页面中提供的内容,然后根据需要修改其内容。将其更改为如下所示的普通双引号可解决以下问题:
{
"webcredentials": {
"apps": [
"ZT978FY6AB.com.company.my.app",
]
}
}
Run Code Online (Sandbox Code Playgroud)
需要澄清的是,此解决方案适用于只是应用程序的应用程序。不需要登录的网站,不需要将凭据从网站带入所需的应用程序,也不需要 webview 登录设置。当我浏览有关自动填充的文档时,这一点并不明显。托管 apple-app-site-association 的网站不需要有任何登录名或任何类型的东西,它可以只是一个带有一些信息的普通网站(可能是关于应用程序或制作应用程序的公司) .
| 归档时间: |
|
| 查看次数: |
7456 次 |
| 最近记录: |