I am trying to send OTP using react-native firebase .Initially it was send otp but from couple of days it throws an un-understandable error when i send OTP using following code.
const [user, setData] = useState(null);
useEffect(async () => {
const subscriber = auth().onAuthStateChanged(async user => {
try {
if (user) {
console.log({user});
console.log(user._verificationId);
await _storeData('user_info', JSON.stringify({phone, ui: user.uid}));
navigation.navigate('App');
} else {
await sendOTP();
}
} catch (error) {
console.log('error in saving data to async', error);
}
});
}, []);
// send OTP to phone
const sendOTP = async () => {
try {
console.log(' <<<<<<sending OTP to phone>>>>>> ');
const confirmation = await auth().signInWithPhoneNumber(phone);
alert(JSON.stringify(confirmation));
setConfirm(confirmation);
console.log({confirmation});
} catch (error) {
console.log(JSON.stringify(error));
}
};
//
// verify OTP here
async function confirmCode() {
try {
if (!user) {
const userProfile = await confirm.confirm(code);
await _storeData(
'user_info',
JSON.stringify({phone, uid: userProfile._verificationId}),
);
navigation.navigate('App');
}
} catch (error) {
showToast('Invalid code.');
console.log('Invalid code.');
}
}
The code was working fine initially but now it throws following message in console :
{"line":6576,"column":64,"sourceURL":"http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.medicineecommerce&modulesOnly=false&runModule=true"}