previously for my project, I tried creating phone authentication on ionic on android the Recaptcha worked and would send OTP without issues however on ios there were issues with Recaptcha. To fix this issue I created a plug-in to call whenever I need to log in and it works perfectly.
import Firebase
import Capacitor
var verification : String = "";
@objc(GetTokenVerification)
public class GetTokenVerification: CAPPlugin {
@objc func GetT(_ call: CAPPluginCall){
let phone : String = call.getString("phone") ?? "null"
PhoneAuthProvider.provider().verifyPhoneNumber(phone, uiDelegate: nil) { (verID, error) in
if(error == nil){
verification = verID ?? "verification failed"
call.resolve([
"verID" : verification
])
}else{
print(error!);
}
}
}
@objc func verifyOpt(_ call: CAPPluginCall){
let varif : String = call.getString("varf") ?? "null"
let OTP : String = call.getString("OTP") ?? "null"
let credentials = PhoneAuthProvider.provider().credential(withVerificationID: varif, verificationCode: OTP)
var mo = Auth.auth().currentUser;
print(mo)
Auth.auth().signInAndRetrieveData(with: credentials) { (success, error) in
if(error == nil){
call.resolve([
"passed" : "login made"
])
}else{
print(error!);
call.reject("error");
}
}
}
}
However, when setting the firebase security rules I faced an issue that this solution doesn't set the auth information to the auth app locking all of the apps with the security rules is there a custom way to set the auth information for the security rules or a better solution to fixing the original Recaptcha issue
thank you for reading and any help is welcome
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…