How to send and verify OTP using cloud function in flutter?
118
-
Setup firebase cloud function here
-
Your js code be like
exports.sendOtp = functions.https.onCall((request, response) => { const options = JSON.stringify({ mobile: request.text, }); const headers = { "Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxx”, }; const res = axios.post(“url”, options, {headers: headers}).then((response) => { console.log(response); return response; }); return res.statusCode; });
-
Your service code be like
Future<void> sendOtp(String mobile) async {
HttpsCallable callable =
FirebaseFunctions.instance.httpsCallable('sendOtp');
final resp = await callable.call(<String, dynamic>{
'text': mobile,
});
}
Comments
-
Steve Vinoski over 1 year
I have API to send and verify otp code. I need to link that API to my flutter app using Firebase clod function. How is it possible Please help ?