i run my code on iOS simulator and phone Authentication is sending OTP to Required phone number and working perfect on Android Device...
The Problem i Have:
i send my code to my boss and my boss run my code on iOS real device to my surprise he his not receiving OTP on real device, and is working on Simulator..
Please can someone tell what is the problem...
Here is my code
Future<void> phoneAuth() async {
try {
final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
(String verId) {
verificationId = verId;
};
final PhoneCodeSent codeSent = (String verId, [int forceCodeResend]) {
verificationId = verId;
setState(() {
next = false;
});
};
final PhoneVerificationCompleted verificationCompleted =
(phoneAuthCredential) {
print('verified');
};
final PhoneVerificationFailed verificationFailed = (error) {
print('$error');
};
await auth.verifyPhoneNumber(
phoneNumber: number123,
verificationCompleted: verificationCompleted,
verificationFailed: verificationFailed,
codeSent: codeSent,
codeAutoRetrievalTimeout: codeAutoRetrievalTimeout,
timeout: Duration(seconds: 5),
);
} catch (e) {
print('this is the error from otp $e');
}
}
Here the function to verify the OTP sent
Future<bool> signIn() async {
try {
//!here is where phone auth start
final AuthCredential phoneCredential = PhoneAuthProvider.credential(
verificationId: verificationId,
smsCode: otpNumberInput.text,
);
final getuser =
await (auth.currentUser.linkWithCredential(phoneCredential));
final user = getuser.user;
await firestore.collection('users').doc(user.uid).update({
'phoneNumber': user.phoneNumber,
});
SharedPreferences pref = await SharedPreferences.getInstance();
pref.setBool('auth', true);
return true;
} catch (e) {
return false;
}
}