How to fix the JS error: The user agent does not support public key credentials

Viewed 2433

I am using the new PasswordCredential API and created this piece of code. It's working. But for some users, it throws this error 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
        }
    });
}

Although I am not using that API, I get that error for many of our users. So, should I check for both condition here like this:

if (window.PasswordCredential && typeof(PublicKeyCredential) != "undefined" ) {

if so, why should I do this check for both?

0 Answers
Related