Comments (5)
If you are using FIrebaseAuth you don't need to use smart_auth to get the SMS code. You just need to handle verificationCompleted
.
await FirebaseAuth.instance.verifyPhoneNumber(
verificationCompleted: (PhoneAuthCredential credential) {
pinController.setText(credential.smsCode);
},
verificationFailed: (FirebaseAuthException e) {},
codeSent: (String verificationId, int? resendToken) {},
codeAutoRetrievalTimeout: (String verificationId) {},
);
from flutter_smart_auth.
I receive messages on my phone, but the auto-fill feature is not working. Here is my code for this issue. Even after receiving a message, the controller value remains empty. Do I need to update something in this code, or is there any configuration I have to adjust in the project?
Here is my sample code:
import 'dart:developer';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:pinput/pinput.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final scaffoldKey = GlobalKey();
final TextEditingController controller = TextEditingController();
sendOtp() async {
FirebaseAuth auth = FirebaseAuth.instance;
await auth.verifyPhoneNumber(
phoneNumber: "+9779860718700",
verificationCompleted: (PhoneAuthCredential credential) async {
controller.setText(credential.smsCode ?? "");
},
verificationFailed: (FirebaseAuthException e) {
log('The provided phone number is not valid.${e.code}');
},
codeSent: (String verificationId, int? resendToken) {},
codeAutoRetrievalTimeout: (String verificationId) {},
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
key: scaffoldKey,
appBar: AppBar(
title: const Text('Plugin example app'),
actions: [
IconButton(
onPressed: () async {
controller.setText("123456");
},
icon: const Icon(Icons.home),
),
IconButton(
onPressed: () async {
log("This is log ${controller.text}");
},
icon: const Icon(Icons.abc),
),
IconButton(
onPressed: () => sendOtp(),
icon: const Icon(Icons.send),
)
],
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(40.0),
child: Pinput(
length: 6,
androidSmsAutofillMethod: AndroidSmsAutofillMethod.none,
// androidSmsAutofillMethod: AndroidSmsAutofillMethod.smsUserConsentApi,
controller: controller,
),
),
),
),
);
}
}
from flutter_smart_auth.
Is the verificationCompleted method called at all?
from flutter_smart_auth.
After invoking the function to send the OTP, the reCAPTCHA check occurs in Chrome. Upon successful verification, the page returns to the app. Subsequently, the SMS is received, but the 'verificationCompleted' method doesn't trigger. Is there an error in my code, or do I need to make any updates? Could you please review my code and correct it if necessary? Thank you.
from flutter_smart_auth.
The code looks good, but I don't understand why firebase_auth is redirecting you to the reCAPTCHA.
from flutter_smart_auth.
Related Issues (16)
- Operation not permitted in IOS HOT 1
- Sms code retrieval is not working when the app is published on the play store HOT 6
- On Android API 34 (Android 14) sms retriever not working. Need to change codes as mentioned in official documentation. HOT 7
- underlying Objective-C module 'smart_auth' not found HOT 1
- Dependency 'androidx.core:core-ktx:1.12.0' requires libraries and applications depend on it to compile against version 34 or later of the Android APIs. HOT 4
- java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=com.example.sms_flutter (has extras) } in fman.ge.smart_auth.SmartAuthPlugin$SmsBroadcastReceiver@79393a2 HOT 3
- Incompatibility with play-services-auth 21.0.0 and google_sign_in_android 6.1.22
- [Q] What are the cases that 'getAppSignature' returns 'N/A'?
- smartAuth.requestHint getting crash HOT 3
- Execution failed for task ':app:checkDebugAarMetadata' HOT 2
- Smart Auth is not working for web app HOT 1
- Error:Execution failed for task ':flutter_smart_auth:compileDebugKotlin'. > Compilation error. See log for more details HOT 4
- Phone number suggestion not working on Android 12 devices HOT 2
- Package incompatible with AGP 4.2<=
- SMS auto fill not working on First time app launch HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_smart_auth.