I want to know how to enable the autocomplete for a login form in Capacitor (or if it's possible).(我想知道如何在Capacitor中启用登录表单的自动填充功能(或者如果可能的话)。)
I'm using Ionic React.(我正在使用Ionic React。) It works if access the page in Safari on iOS and even if you pin it to the home screen.(即使在iOS上的Safari中访问该页面,即使将其固定到主屏幕,也可以使用。) But if you bundle the web app in Capacitor, the autocomplete is not there.(但是,如果将Web应用程序捆绑在Capacitor中,则自动完成功能将不存在。) Here's the code for the login form:(这是登录表单的代码:)
<form onSubmit={e => loginAndCloseModal({e, emailValue, passwordValue})}>
<IonList>
<IonItem>
<IonLabel position="stacked">Email</IonLabel>
<IonInput autocomplete="username" name="email" value={emailValue} onIonChange={e => setEmail(e.target.value)}></IonInput>
</IonItem>
<IonItem>
<IonLabel position="stacked">Password</IonLabel>
<IonInput autocomplete="current-password" name="password" type="password" value={passwordValue} onIonChange={e => setPassword(e.target.value)}></IonInput>
</IonItem>
{ errorMessage &&
<IonItem>
<IonNote color="danger">{errorMessage}</IonNote>
</IonItem> }
</IonList>
<IonButton class="login-button" expand="block" type="submit" disabled={authLoading}>Login</IonButton>
</form>
I've also tried setting autocomplete="on"
as well and it didn't work.(我也尝试过将autocomplete="on"
设置为无效,但这没有用。)
Apple's documentation recommends using the values posted above: https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_an_html_input_element(Apple的文档建议使用上面发布的值: https : //developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_an_html_input_element)
Here's a screenshot of the login page on the web:(这是网络上登录页面的屏幕截图:)
Here's a version of the login form in Capacitor:(这是电容器中登录表单的版本:)
Notice the passwords option in the above the keyboard is gone.(请注意,键盘上方的密码选项已消失。)
Why is that?(这是为什么?)
Here's the relevant dependencies of my project:(这是我项目的相关依赖项:)
"@capacitor/cli": "^1.2.1",
"@capacitor/core": "^1.2.1",
"@capacitor/ios": "^1.2.1",
"@ionic/react": "^4.11.2",
"@ionic/react-router": "^4.11.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
I'm using iOS version 12.4.2(我正在使用iOS版本12.4.2)
EDIT:(编辑:)
I've done some more research.(我做了更多的研究。)
There this documentation from Apple.(那里有苹果公司的这份文件。) The relevant section is this:(相关部分是这样的:)
Enable Password AutoFill(启用密码自动填充)
Password AutoFill uses heuristics to determine when the user logs in or creates new passwords, and automatically provides the password QuickType bar.(密码自动填充使用启发式方法确定用户何时登录或创建新密码,并自动提供密码快速输入栏。)
These heuristics give users some Password AutoFill support in most apps, even if those apps haven't been updated to support AutoFill.(这些启发式方法为用户提供了大多数应用程序中的一些密码自动填充支持,即使这些应用程序尚未更新为支持自动填充也是如此。) However, to provide the best user experience and ensure your app fully supports Password AutoFill, perform the following steps:(但是,为了提供最佳的用户体验并确保您的应用程序完全支持密码自动填充,请执行以下步骤:)
Set up your app's associated domains.(设置您应用的关联域。)
To learn how to set up your app's associated domains, see Setting Up an App's Associated Domains.(要了解如何设置应用程序的关联域,请参阅设置应用程序的关联域。)
Set the correct AutoFill type on relevant text fields.(在相关文本字段上设置正确的自动填充类型。)
For an iOS app, see Enabling Password AutoFill on a Text Input View.(对于iOS应用,请参阅在文本输入视图上启用密码自动填充。) For a web app, see Enabling Password AutoFill on an HTML Input Element.(对于Web应用程序,请参阅在HTML Input Element上启用密码自动填充。)
I did 2 from above when I first asked this question, but not 1. However after doing number 1 it's still not working.(当我第一次问这个问题时,我是从上面做2个,但是没有做1个。但是在做完第1个之后,它仍然不起作用。)
Here's some more relevant documentation from Apple.(这是Apple提供的一些更相关的文档。)
ask by CovertIII translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…