Tkko / flutter_smart_auth

Flutter package for listening SMS code on Android, suggesting phone number, email, saving a credential.
https://pub.dev/packages/smart_auth
MIT License
43 stars 26 forks source link

Smart Auth isn't showing any dialog to the user when a code is received on device. #23

Closed Nana-Kwame-bot closed 4 months ago

Nana-Kwame-bot commented 4 months ago

Describe the bug I'm not sure if it's my improper setup issue or not but I want to only use the UserConsentApi and so I didn't setup any app signatures. If I still need to do so although I'm not using the retriever api please let me know.

class OtpRetriever implements SmsRetriever {
  const OtpRetriever({
    required String senderPhoneNumber,
    required SmartAuth smartAuth,
  })  : _smartAuth = smartAuth,
        _senderPhoneNumber = senderPhoneNumber;

  final SmartAuth _smartAuth;
  final String _senderPhoneNumber;

  @override
  bool get listenForMultipleSms => false;

  @override
  Future<void> dispose() => _smartAuth.removeSmsListener();

  @override
  Future<String?> getSmsCode() async {
    AppLogger.i("OtpRetriever: Fetching SMS code...");

    final res = await _smartAuth.getSmsCode(
      senderPhoneNumber: _senderPhoneNumber,
      useUserConsentApi: true,
    );

    AppLogger.i(
      "OtpRetriever: SMS fetch result - ${res.succeed} ${res.codeFound} ${res.code}",
    );

    return res.succeed && res.codeFound ? res.code : null;
  }
}

SmartAuth version: [2.0.0]

Result of: flutter doctor --verbose

[✓] Flutter (Channel stable, 3.22.0, on macOS 12.7.5 21H1222 darwin-x64, locale en-GH) • Flutter version 3.22.0 on channel stable at /usr/local/Caskroom/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5dcb86f68f (9 weeks ago), 2024-05-09 07:39:20 -0500 • Engine revision f6344b75dc • Dart version 3.4.0 • DevTools version 2.34.3 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/user/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/user/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) • All Android licenses accepted. [!] Xcode - develop for iOS and macOS (Xcode 14.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14C18 ! Flutter recommends a minimum Xcode version of 15. Download the latest version or update via the Mac App Store. • CocoaPods version 1.15.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) [✓] Android Studio (version 2022.1) • Android Studio at /Users/user/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9619390/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301) [✓] VS Code (version 1.91.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.92.0 [✓] VS Code (version 1.80.0-insider) • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents • Flutter extension version 3.67.20230601 [✓] Connected device (3 available) • Infinix X650 (mobile) • 192.168.0.158:5555 • android-arm • Android 8.1.0 (API 27) • macOS (desktop) • macos • darwin-x64 • macOS 12.7.5 21H1222 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category.

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

If I just want to set up the user consent API, any help would be appreciated.

I see this OtpRetriever: Fetching SMS code... in the console twice.

Tkko commented 4 months ago

Hi @Nana-Kwame-bot, everything looks good. Is the senderPhone matching the actual SMS sender? Also try to remove it to see if it works without it.

Nana-Kwame-bot commented 4 months ago

@Tkko I removed the sms sender number and it works fine. Thanks :)