Reputation: 1
Iam working in reactjs login page with otp code login. I want to auto-fill my OTP. I used The code below but there is no response for navigator.credential.get() in my app could any one help me how to fix this.
const handleOtpRetrieval = () => {
const ac = new AbortController()
navigator.credentials.get({
otp: { transport: ['sms'] },
signal: ac.signal
}).then(otp => {
alert(`got otp from client===>${otp}`)
}).catch(err => {
alert(`err: ${err}`)
})
}
useEffect(() => {
/**OTPConnection**/
if ('OTPCredential' in window) {
handleOtpRetrieval()
}
}
}, [])
sms format:
OTP:123456
@domain.info #123456
working on https and sms format rules passed and try above code return no alert in my code
Upvotes: 0
Views: 1055
Reputation: 1
I just changed sms format to below
OTP:123456.
@www.domain.info #123456
and it works for me.
Upvotes: 0