Pramod Singh

Pramod Singh

  • 1.4k
  • 390
  • 34.2k

WebOTP in Angular Application for both Android & IOS - Not working

Feb 20 2024 12:25 PM

Hi Team,

 

I Implimented WebOTP in my Angular application and it's working perfect in Android chome browser but when i tested in Iphone 13 IOS Chome browser then it's not working due to first if condition getting failed --> if ('OTPCredential' in window) {

 

Below is code is used:

 try {
 
   if ("OTPCredential" in window) {      
     try {
       if (navigator.credentials) {           
         const ac = new AbortController();
         setTimeout(() => {
           ac.abort();
         }, 60 * 1000);

         let o = {
           otp: { transport: ['sms'] },
           signal: ac.signal
         };
         await navigator.credentials.get(o).then((otp: any) => {
          
           alert(otp['code'])
          
            
            
             ac.abort();
           }
        
         }).catch((err) => {
           console.log(err);
         });
       };
     }
     catch (e) {
       console.log(e)
     }
   }
 }
 catch (e) {
   console.log(e)
 }

 

 

Please help..


Answers (4)