我正在使用新的PasswordCredential API并创建了这段代码。工作正常但是对于某些用户,它会引发此错误The user agent does not support public key credentials.
if (window.PasswordCredential) {
navigator.credentials.get({
password: true,
mediation: 'optional'
}).then(credential => {
if (credential) {
if (credential.type === 'password') {
// authenticate the user with obtained credentials
}
});
}
尽管我没有使用该API,但我的许多用户都遇到了该错误。所以,我应该在这里检查这两种情况吗?
if (window.PasswordCredential && typeof(PublicKeyCredential) != "undefined" ) {
如果是这样,为什么我要对两者都进行检查?