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..


Jayraj ChhayaRank #304 · 8.2K reputationPosted Feb 20, 2024, 8:18 AM EST
I think the problem lies in the way WebOTP is supported on different platforms. While Android devices support the
OTPCredentialinterface, iOS devices do not have native support for it.The condition
if ("OTPCredential" in window)fails on iOS devices, leading to the code block not being executed.try { if ("OTPCredential" in window) { const ac = new AbortController(); setTimeout(() => { ac.abort(); }, 60 * 1000); let o = { otp: { transport: ['sms'] }, signal: ac.signal }; navigator.credentials.get(o).then((otp: any) => { alert(otp['code']); ac.abort(); }).catch((err) => { console.log(err); }); } else { // Fallback mechanism for devices without OTPCredential support // Implement an alternative OTP retrieval method here } } catch (e) { console.log(e); }Try this code might be it work
Batista Dave24 reputationPosted Feb 21, 2024, 2:33 AM EST
Troubleshooting WebOTP in Angular applications for both Android and iOS requires a meticulous approach. Ensure you've followed the standards and prerequisites for WebOTP implementation, including compatibility with Android and iOS browsers. Check if the necessary permissions are granted, and validate the integration with respective OTP providers. Debugging tools like Chrome Developer Tools or Safari Developer Tools can help diagnose issues. Additionally, consider testing on different devices and browser versions to pinpoint platform-specific discrepancies. If issues persist, consult Angular development services and WebOTP documentation, or seek assistance from relevant forums or communities for targeted support.
Pramod SinghRank #2,091 · 687 reputationPosted Mar 7, 2024, 3:55 AM EST
No it's not working. Basically i need to onpaste event wheile user click on his iphone chrome browser once he got the message. then it's going to get those otp at typescript file in angular. so is there any way ?
benjaminlouis5 reputationPosted Mar 23, 2024, 12:19 AM EDT
click here