Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
自动填充WebOTP javascript api不工作_Javascript_Reactjs_Web_Webapi_One Time Password - Fatal编程技术网

自动填充WebOTP javascript api不工作

自动填充WebOTP javascript api不工作,javascript,reactjs,web,webapi,one-time-password,Javascript,Reactjs,Web,Webapi,One Time Password,我尝试了许多示例代码,但都不起作用 console.log("Otp.js>13 mounted"); if ('OTPCredential' in window) { try { console.log("Otp.js>16 in otpcredential"); if (navigator.credentials) { try { console

我尝试了许多示例代码,但都不起作用

console.log("Otp.js>13 mounted");
if ('OTPCredential' in window) {
    try {
        console.log("Otp.js>16 in otpcredential");
        if (navigator.credentials) {
            try {
                console.log("Otp.js>19 credential");
                let {type,code} = await navigator.credentials.get({ otp:{ transport: ['sms']}})
                console.log("EsignSteps.js>78 aaaayo",type,code);
            }
            catch (e) {
                console.log("EsignSteps.js>81",e);
            }
        }
    }
    catch (err) {
        console.log("40",err);
    }
}
上面的代码在几分钟后给出了DomeException,即使在我收到OTP之后

我也试过了

const abort = new AbortController();

setTimeout(() => {
  abort.abort();
}, 2 * 60 * 1000);

let {type,code} = await navigator.credentials.get({ signal: abort.signal,otp:{ transport: ['sms']}})
也试过

navigator.credentials.get({ signal: abort.signal,otp:{ transport: ['sms']}})
.then((otp)=>{
console.log(otp);
})
.catch(err=>{
console.log(err);
})
我尝试过许多短信格式,如:

格式1:

Your OTP is : 123456
@https://example.com #123456
格式2:

Your OTP is : 123456
@example.com #123456
格式3:

Your OTP is : 123456
@www.example.com #123456
我已经看过了这本书的最小细节

我试过一些演示,比如,
不起作用的

我找到了解决办法。我是从我朋友的手机号码发送短信的,手机号码保存在我的联系人列表中。 如果发送方的电话号码包含在接收方的联系人列表中,则由于基础应用程序的设计,将不会触发此API