Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase_auth] sms code auto retrieval (auto detect and login) not working after upgrading to 0.20.0 #4916

Closed
rameshm123 opened this issue Feb 2, 2021 · 27 comments
Labels
plugin: auth type: bug Something isn't working

Comments

@rameshm123
Copy link

rameshm123 commented Feb 2, 2021

Bug report

Describe the bug
after updating the firebase plugins firebase phone auth SMS code auto-detect and login not working.
SMS is receiving and also able to log in but auto code detects not working.

Steps to reproduce

Steps to reproduce the behavior:

Using these latest version to firebas plugins

  cloud_firestore: ^0.16.0
  firebase_analytics: ^7.0.1
  firebase_auth: ^0.20.0
  firebase_core: ^0.7.0
  firebase_crashlytics: ^0.4.0

Expected behavior

Need to auto detect the sms code or verificationId and logged in.
Previously it was working. After firebase plugin upgrade it is not working.


Flutter doctor

Run flutter doctor and paste the output below:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.16299.1127], locale en-US)
/Error 1 retrieving device properties for ro.product.cpu.abi:
error: closed


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[!] Android Studio (version 4.1.0)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code, 64-bit edition (version 1.52.1)
[√] Connected device (1 available)
    ! Device 192.168.1.201:5083 is offline.

! Doctor found issues in 1 category.

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Dart SDK 2.10.5
Flutter SDK 1.22.6
caremother 3.6.5+34

dependencies:
- android_alarm_manager 0.4.5+20 [flutter]
- audioplayers 0.16.2 [uuid path_provider flutter flutter_web_plugins]
- auto_size_text 2.1.0 [flutter]
- cached_network_image 2.5.0 [flutter flutter_cache_manager octo_image]
- cloud_firestore 0.16.0 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- connectivity 2.0.2 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web]
- contacts_service 0.4.6 [flutter collection quiver]
- countdown 0.1.0
- cupertino_icons 1.0.0
- custom_radio_grouped_button 1.0.6+1 [flutter]
- dots_indicator 1.2.0 [flutter]
- dotted_border 1.0.7 [flutter path_drawing]
- easy_localization 2.3.3 [flutter intl shared_preferences args path flutter_localizations]
- easy_onboarding 0.0.2 [flutter]
- easy_pip 0.1.0 [flutter]
- esys_flutter_share 1.0.2 [flutter path_provider]
- firebase_analytics 7.0.1 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_auth 0.20.0 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.7.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_crashlytics 0.4.0 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface]
- firebase_dynamic_links 0.7.0+1 [flutter firebase_core]
- firebase_messaging 8.0.0-dev.13 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web]
- firebase_storage 7.0.0 [flutter firebase_core firebase_core_platform_interface firebase_storage_web firebase_storage_platform_interface quiver]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_absolute_path 1.0.6 [flutter]
- flutter_barcode_scanner 1.0.2 [flutter flutter_plugin_android_lifecycle]
- flutter_calendar_carousel 1.5.2 [intl flutter]
- flutter_countdown_timer 2.1.0 [flutter]
- flutter_downloader 1.5.2 [flutter]
- flutter_full_pdf_viewer 1.0.6 [flutter]
- flutter_image_compress 0.7.0 [flutter]
- flutter_launcher_icons 0.8.1 [image args yaml path]
- flutter_local_notifications 3.0.2 [flutter platform flutter_local_notifications_platform_interface timezone]
- flutter_screenutil 3.2.0 [flutter]
- flutter_sms 2.1.1 [flutter url_launcher flutter_web_plugins plugin_platform_interface flutter_user_agent]
- flutter_staggered_animations 0.1.2 [flutter]
- flutter_staggered_grid_view 0.3.3 [flutter]
- flutter_svg 0.19.1 [flutter meta path_drawing vector_math xml]
- flutter_swiper 1.1.6 [flutter transformer_page_view flutter_page_indicator]
- flutter_widgets 0.1.12 [collection flutter html meta quiver]
- geocoder 0.2.1 [meta flutter]
- geolocator 6.1.13 [flutter geolocator_platform_interface]
- google_maps_flutter 1.0.10 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface]
- google_nav_bar 3.2.0 [flutter]
- heic_to_jpg 0.1.3 [flutter]
- image_cropper 1.3.1 [flutter]
- image_downloader 0.20.1 [flutter]
- image_picker 0.6.7+21 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- in_app_update 1.1.15 [flutter]
- intl 0.16.1 [path]
- json_serializable 3.5.1 [analyzer build build_config json_annotation meta path source_gen]
- link_previewer 1.2.1 [flutter async html http url_launcher]
- multi_image_picker 4.7.14 [flutter meta]
- open_file 3.0.3 [flutter ffi]
- package_info 0.4.3+2 [flutter]
- page_view_indicators 1.4.0 [flutter]
- path_provider 1.6.27 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- pdf 1.13.0 [archive barcode crypto image meta path_parsing vector_math xml]
- permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface]
- photo_view 0.10.3 [flutter]
- pin_code_text_field 1.7.1 [flutter]
- printing 3.7.2 [flutter flutter_web_plugins image js meta pdf plugin_platform_interface]
- provider 4.3.2+3 [collection flutter nested]
- quiver 2.1.5 [matcher meta]
- rxdart 0.24.1
- share 0.6.5+4 [meta mime flutter]
- share_extend 1.1.9 [meta flutter]
- shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- shimmer 1.1.2 [flutter]
- sleek_circular_slider 1.2.0+web [flutter]
- smart_select 4.3.2 [flutter]
- step_progress_indicator 0.2.5+8 [flutter]
- story_view 0.12.6 [flutter flutter_cache_manager rxdart video_player]
- swipe_stack 1.0.0 [flutter]
- system_alert_window 0.4.2+2 [flutter]
- timezone 0.5.9 [path]
- upgrader 2.8.0 [flutter device_info flutter_device_locale http package_info shared_preferences url_launcher version xml]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- webview_media 0.1.2 [flutter]
- xml 4.5.1 [collection convert meta petitparser]
- youtube_player_flutter 7.0.0+7 [flutter flutter_inappwebview]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- _fe_analyzer_shared 14.0.0 [meta]
- analyzer 0.41.1 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- archive 2.0.13 [crypto args path]
- args 1.6.0
- async 2.5.0-nullsafety.1 [collection]
- barcode 1.17.1 [meta qr]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- build 1.6.1 [analyzer async convert crypto glob logging meta path]
- build_config 0.4.5 [checked_yaml json_annotation meta path pubspec_parse yaml]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- checked_yaml 1.0.4 [json_annotation source_span yaml]
- cli_util 0.2.0 [path]
- clock 1.1.0-nullsafety.1
- cloud_firestore_platform_interface 3.0.1 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.3.0+1 [flutter flutter_web_plugins http_parser meta firebase_core firebase_core_web cloud_firestore_platform_interface js]
- collection 1.15.0-nullsafety.3
- connectivity_for_web 0.3.1+4 [connectivity_platform_interface flutter_web_plugins flutter]
- connectivity_macos 0.1.0+7 [flutter]
- connectivity_platform_interface 1.0.6 [flutter meta plugin_platform_interface]
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- csslib 0.16.2 [source_span]
- dart_style 1.3.10 [analyzer args path source_span]
- device_info 1.0.0 [flutter device_info_platform_interface]
- device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase 7.3.3 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_auth_platform_interface 3.0.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.2+6 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js]
- firebase_core_platform_interface 3.0.1 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1+3 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- firebase_crashlytics_platform_interface 1.1.6 [flutter meta collection firebase_core plugin_platform_interface]
- firebase_messaging_platform_interface 1.0.0-dev.9 [flutter meta firebase_core plugin_platform_interface]
- firebase_messaging_web 0.1.0-dev.4 [flutter flutter_web_plugins meta firebase_core firebase_core_web firebase_messaging_platform_interface js service_worker]
- firebase_storage_platform_interface 1.0.4 [flutter meta collection firebase_core plugin_platform_interface]
- firebase_storage_web 0.1.1+3 [async crypto firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta]
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 2.1.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image]
- flutter_device_locale 0.4.0 [flutter flutter_web_plugins plugin_platform_interface]
- flutter_inappwebview 4.0.0+4 [flutter uuid mime]
- flutter_local_notifications_platform_interface 2.0.0+1 [flutter plugin_platform_interface]
- flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math]
- flutter_page_indicator 0.0.3 [flutter]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_user_agent 1.2.2 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- geolocator_platform_interface 1.0.8 [flutter meta plugin_platform_interface vector_math]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- google_maps_flutter_platform_interface 1.0.5 [flutter meta plugin_platform_interface stream_transform]
- html 0.14.0+4 [csslib source_span]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image 2.1.19 [archive xml meta]
- image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface]
- js 0.6.2
- json_annotation 3.1.1
- logging 0.11.4
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- mime 0.9.7
- nested 0.0.4 [flutter]
- node_interop 1.2.1 [js]
- node_io 1.2.0 [file node_interop path]
- octo_image 0.3.0 [flutter flutter_blurhash]
- package_config 1.9.3 [path charcode]
- path 1.8.0-nullsafety.1
- path_drawing 0.4.1+1 [vector_math meta path_parsing flutter]
- path_parsing 0.1.4 [vector_math meta]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+8 [flutter]
- path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- process 3.0.13 [file intl meta path platform]
- pub_semver 1.4.4 [collection]
- pubspec_parse 0.1.7 [checked_yaml json_annotation pub_semver yaml]
- qr 1.3.0 [meta]
- service_worker 0.2.4 [js]
- shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+3 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- sky_engine 0.0.99
- source_gen 0.9.10+1 [analyzer async build dart_style glob meta path pedantic source_span]
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- sqflite 1.3.2+1 [flutter sqflite_common path]
- sqflite_common 1.0.2+1 [synchronized path meta]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- stream_transform 1.2.0
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- transformer_page_view 0.1.6 [flutter]
- typed_data 1.3.0-nullsafety.3 [collection]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5+1 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+3 [flutter]
- uuid 2.2.2 [crypto convert]
- vector_math 2.1.0-nullsafety.3
- version 1.2.0
- video_player 1.0.1 [meta video_player_platform_interface video_player_web flutter]
- video_player_platform_interface 2.2.0 [flutter meta]
- video_player_web 0.1.4+1 [flutter flutter_web_plugins meta video_player_platform_interface]
- watcher 0.9.7+15 [async path pedantic]
- win32 1.7.4 [ffi]
- xdg_directories 0.1.2 [meta path process]
- yaml 2.2.1 [charcode collection string_scanner source_span]

@rameshm123 rameshm123 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Feb 2, 2021
@markusaksli-nc
Copy link
Contributor

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Feb 3, 2021
@rameshm123
Copy link
Author

Hello @markusaksli-nc
already enable the
Android Device Verification from GCP.

but still it's not working.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Feb 3, 2021
@markusaksli-nc
Copy link
Contributor

Is it opening up ReCaptcha or is anything relevant logged to the console?

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Feb 4, 2021
@Ehesp
Copy link
Member

Ehesp commented Feb 4, 2021

Can you also show some code please?

@rameshm123
Copy link
Author

@markusaksli-nc there is no log relevant to this issue..
Everything is working fine just the device is unable to auto retrieve the code and login. We have to enter the code and log in manually.
Previously it was working fine. But after the firebase plugin upgrade, this issue occurred.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Feb 4, 2021
@rameshm123
Copy link
Author

rameshm123 commented Feb 4, 2021

hello @Ehesp

The below code is for firebase phone auth verification

void _signInWithPhoneNumber(
      BuildContext context, String verificationId, String otp) async {
    debugPrint("smsCode $verificationId otp $otp");
    AuthCredential _authCredential = await PhoneAuthProvider.credential(
        verificationId: verificationId, smsCode: otp);
    FirebaseAuth.instance
        .signInWithCredential(_authCredential)
        .catchError((error) {
      debugPrint("_signInWithPhoneNumber manual failed ${error.toString()}");

      setState(() {
        _isLoading = false;
      });

      final snackBar = SnackBar(
          content: Text("Authentication Failed"),
          duration: Duration(seconds: 1));
      //debugPrint(error.toString());
      _scaffoldKey.currentState.showSnackBar(snackBar);
    }).then((value) {
//      debugPrint("_signInWithPhoneNumber manual success ${value.user.uid}");
      if (value != null) {
        widget._users.uid = value.user.uid;
        _userBloc.getUser(widget._users.phoneNumber, widget._users.uid);

        setState(() {
          _uid = widget._users.uid;

          //  _isLoading = false;
        });
      }
    });
  }

  _verifyPhoneNumber(BuildContext context) async {
    setState(() {
      _isOTPRecieved = false;
    });
    String phoneNumber = "+91" + _users.phoneNumber;
    debugPrint("phoneNo $phoneNumber");
    final FirebaseAuth _auth = FirebaseAuth.instance;
    await _auth.verifyPhoneNumber(
        phoneNumber: phoneNumber,
        timeout: Duration(seconds: 60),
        verificationCompleted: (authCredential) =>
            _verificationComplete(authCredential, context),
        verificationFailed: (authException) =>
            _verificationFailed(authException, context),
        codeAutoRetrievalTimeout: (verificationId) =>
            _codeAutoRetrievalTimeout(verificationId),
        // called when the SMS code is sent
        codeSent: (verificationId, [int forceResendToken]) =>
            _smsCodeSent(verificationId, forceResendToken));
  }

  /// will get an AuthCredential object that will help with logging into Firebase.
  _verificationComplete(AuthCredential authCredential, BuildContext context) {
    FirebaseAuth.instance
        .signInWithCredential(authCredential)
        .then((authResult) {
      debugPrint("_signInWithPhoneNumber auto success ${authResult.user.uid}");
      _users.uid = authResult.user.uid;

      debugPrint("verfication complete");
      // _userBloc.getUser(_phoneNumber, _users.uid);
      _userBloc.getUser(_users.phoneNumber, authResult.user.uid);
      setState(() {
        _uid = authResult.user.uid;
        _isAutoOtp = false;
        //  _isLoading = false;
      });
      //todo navigate user to otp screen

      //Navigator.of(context).pushReplacementNamed('loginOtp', arguments: _users);
    });
  }

  _smsCodeSent(String verificationId, forceResendToken) {
    setState(() {
      _isLoading = false;
      _isOtpSent = true;
    });
    // set the verification code so that we can use it to log the user in
    _smsVerificationCode = verificationId;

    if (_smsVerificationCode != null || _smsVerificationCode != '') {
      _initializeTimer();
      setState(() {
        _loadingMsgIntial = "";
        _isOTPRecieved = true;
      });
    }

    debugPrint("_smsVerificationCode ${_smsVerificationCode} ");
    debugPrint("verificationId ${verificationId}");
    setState(() {
      _currentTime = 60;
      _isTimeElapse = false;
      // _initializeTimer();
    });
    final snackBar = SnackBar(
      content: Text(
        "otp.new_otp_sent".tr(args: ['$_users.phoneNumber'.toString()]),
      ),
      duration: Duration(seconds: 2),
      behavior: SnackBarBehavior.floating,
    );
    Timer(Duration(milliseconds: 2500), () {
      setState(() {
        _isOtpSent = false;
        _isAutoOtp = true;
      });
    });
    // _scaffoldKey.currentState.showSnackBar(snackBar);
  }

  _verificationFailed(
      FirebaseAuthException authException, BuildContext context) {
    debugPrint("authException ${authException.message.toString()}");
    setState(() {
      _isLoading = false;
      _isAutoOtp = false;
    });

    final snackBar = SnackBar(
      content: Text(authException.message.toString()),
      duration: Duration(seconds: 2),
    );
    _scaffoldKey.currentState.showSnackBar(snackBar);
  }

  _codeAutoRetrievalTimeout(String verificationId) {
    // set the verification code so that we can use it to log the user in
    debugPrint("timeout");
    debugPrint("sms code auto retrieval");

    setState(() {
      _isLoading = false;
      _smsVerificationCode = verificationId;
      _isAutoOtp = false;
    });
    debugPrint("_codeAutoRetrievalTimeout $verificationId");
  }

@markusaksli-nc
Copy link
Contributor

Have you tested this with multiple phone numbers or just one?

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Feb 4, 2021
@rameshm123
Copy link
Author

@markusaksli-nc
Tested on multiple devices with multiple numbers too.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Feb 4, 2021
@markusaksli-nc
Copy link
Contributor

There was a report of this in #4665 as well. I think I saw this as well after first enabling device verification. It might just take some time to work again.

Labeling this for now.

@markusaksli-nc markusaksli-nc added plugin: auth and removed Needs Attention This issue needs maintainer attention. labels Feb 5, 2021
@markusaksli-nc markusaksli-nc changed the title 🐛 [firebase_auth] sms code auto retrieval (auto detect and login) not working 🐛 [firebase_auth] sms code auto retrieval (auto detect and login) not working after upgrading to 0.20.0 Feb 5, 2021
@priezz
Copy link

priezz commented Feb 25, 2021

Hello, I have exactly the same issue. Last version of firebase_auth where auto retrieval works is 0.18.4+1 (used with firebase_core ^0.5.2). With any newer version it does not work. In the console I have the following, which looks to be relevant:

W/BpBinder(29130): Slow Binder: BpBinder transact took 344 ms, interface=com.google.android.gms.auth.api.phone.internal.ISmsRetrieverApiService, code=1 oneway=false
W/FirebaseAuth(29130): [SmsRetrieverHelper] Timed out waiting for SMS.

I confirm that the issue is not device or debug/release mode dependent.

Adding manually the following code into the AndroidManifest.xml does not help:

        <!-- Auto retreive SMS codes -->
        <receiver android:exported="true" android:name="io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingReceiver" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </receiver>

Downgrading the package version to 0.18.4+1/0.5.2 resolves the issue, but it's hard to keep it as soon as we plan to move the codebase to null-safety.

EDIT: "Android Device Verification" was enabled about a month ago. Were there any additional steps required besides just enabling? Maybe google-services.json update or something else...

@markusaksli-nc
Copy link
Contributor

If you have the correct SHA-256 key in firebase console then nothing else should be necessary.

@priezz
Copy link

priezz commented Feb 26, 2021

If you have the correct SHA-256 key in firebase console then nothing else should be necessary.

I do have it

@priezz
Copy link

priezz commented Feb 28, 2021

I have checked, every time an sms message arrives I immediately get the following in the log:

W/BpBinder(29130): Slow Binder: BpBinder transact took 344 ms, interface=com.google.android.gms.auth.api.phone.internal.ISmsRetrieverApiService, code=1 oneway=false

(of course ID and time differ)

@dgilperez
Copy link

We are experiencing exactly the same after upgrade.

Activated Android Device Verification API, added SHA256, updated google-services.json ... everything works except for the auto retrieval.

It's a bit of a blocking thing for us, even more when we just upgraded to null safety.

Any updates from anyone?

Hello, I have exactly the same issue. Last version of firebase_auth where auto retrieval works is 0.18.4+1 (used with firebase_core ^0.5.2). With any newer version it does not work. In the console I have the following, which looks to be relevant:

W/BpBinder(29130): Slow Binder: BpBinder transact took 344 ms, interface=com.google.android.gms.auth.api.phone.internal.ISmsRetrieverApiService, code=1 oneway=false
W/FirebaseAuth(29130): [SmsRetrieverHelper] Timed out waiting for SMS.

I confirm that the issue is not device or debug/release mode dependent.

Adding manually the following code into the AndroidManifest.xml does not help:

        <!-- Auto retreive SMS codes -->
        <receiver android:exported="true" android:name="io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingReceiver" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </receiver>

Downgrading the package version to 0.18.4+1/0.5.2 resolves the issue, but it's hard to keep it as soon as we plan to move the codebase to null-safety.

EDIT: "Android Device Verification" was enabled about a month ago. Were there any additional steps required besides just enabling? Maybe google-services.json update or something else...

@IncognitoGK9
Copy link

I also confirm, this issue is resolved by downgrading the irebase_auth: ^0.18.4+1
#firebase_auth: "^0.20.1" and firebase_core: ^0.5.2 #firebase_core: "^0.7.0"

@a1111198
Copy link

I have been suffering from the same issue then I Found a Solution:
using #firebase_core: "^0.7.0" and #firebase_auth: "^0.20.1" :

First, discuss issue why this issue is occurring:

This started after #firebase ^0.18.0" because After this enabling SafetyNet is mandatory to avoid reCaptcha verification and thus auto-verification is disabled. And If we try to use google Automatic retriever API then A hash must be associated with the message.
But we all know that the Firebase message is like this: 030432 is your verification code for the app name. So this solution would not work.

Now Solution:

If you have created Your Firebase Project After December 2020 then the Firebase message is like this 667816 is your verification code for the app name.1#/##K#Aq5V this 11 digits hash is RSA256 signature based on the package name and SHA fingerPrints.
So this would support Automatic retriever API or alternatively you can use this sms_autoFill.
If you have a project before this then you can contact to support or create A new project but keep in mind change package name:

PS: I am not From Firebase support what I have shared is my experience hope This would help the community.

@dgilperez
Copy link

@a1111198 thanks for sharing. Just to confirm, does this solution works for you on firebase_auth 1.2 or similar, or did you downgrade to previous versions before null-safety?

@a1111198
Copy link

This solution is working for both versions before null Safety and after Null Safety. In one project I am using a version before null safety and in one I am using a version after null safety and For both working fine.
keep in mind 11 digit code after the message is necessary.

@a1111198 thanks for sharing. Just to confirm, does this solution works for you on firebase_auth 1.2 or similar, or did you downgrade to previous versions before null-safety?

@SupremNandalDev
Copy link

Do we have any update on this?
I need it to work the correct way without any workaround.
Working on a client project and I'm so stuck here.
Please update if someone is working on this.

@marcscherer
Copy link

It seems this is not a flutter specific problem:
firebase/firebase-android-sdk#2688

@Shiba-Kar
Copy link

  firebase_auth: ^3.0.1
  firebase_dynamic_links: ^2.0.7
  firebase_messaging: ^10.0.4

Which versions should I set so that i have no conflicts with firebase_core and auto OTP detection works

@russellwheatley
Copy link
Member

russellwheatley commented Jul 30, 2021

Hey @rameshm123, I suspect this could be a problem with the android sdk upstream.

The workaround until the problem is resolved is to shorten your app name on Google Playstore to around 10-15 characters. Could someone let me know if this workaround resolves the issue?

@ElshiatyTube
Copy link

  firebase_auth: ^3.0.1
  firebase_dynamic_links: ^2.0.7
  firebase_messaging: ^10.0.4

Which versions should I set so that i have no conflicts with firebase_core and auto OTP detection works

Thanx @Shiba-Ka this solution is working

@adifyr
Copy link

adifyr commented Sep 5, 2021

I have checked, every time an sms message arrives I immediately get the following in the log:

W/BpBinder(29130): Slow Binder: BpBinder transact took 344 ms, interface=com.google.android.gms.auth.api.phone.internal.ISmsRetrieverApiService, code=1 oneway=false

(of course ID and time differ)

I'm facing the same issue AND getting the same log message as above.

However, my situation is peculiar. We have a Test Firebase/Flutter Project and a Live Firebase/Flutter Project for the same App. For me the Auto-Verification is working on the Test Project and not the Live Project.

Here are my Firebase Plugin Versions in both of my pubpsec.yaml files:

firebase_core: ^1.6.0
firebase_auth: ^3.1.0

Rolling back to previous versions did not help. Once again, on my Test Setup, the auto-detect Is working just fine. This is so confusing. Need help!

@russellwheatley
Copy link
Member

@adifyr Did you read this thread? firebase/firebase-android-sdk#2688

In a nutshell; shorten your app name to 10-15 characters on Playstore, and also ensure there are no special characters.

@russellwheatley
Copy link
Member

Closing as a solution is provided, and there is nothing to action here from a Flutterfire perspective.

@ajesh123
Copy link

You have to generate 11 character hash key for sms retrieval. See the link useful:
https://stackoverflow.com/questions/51365778/how-to-generate-11-char-hash-key-for-sms-retriever-with-google-app-signing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: auth type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

16 participants