简体   繁体   中英

Firebase Phone Auth verificationId never being set. (Flutter iOS)

Okay, hopefully quick question, but for some reason in my current project, the call to actually create and set my verificationId from firebase_auth doesn't ever seem to get called.

Code Snippet involved.

final PhoneCodeSent smsCodeSent = (String verID, [int forceCodeResent]) async {
   this.verificationId = verID;
   print('Setting verificationId');
};

print('Creating Verification Code for: ' + this.phoneNumber);
await _auth.verifyPhoneNumber(
  phoneNumber: this.phoneNumber, 
  codeAutoRetrievalTimeout: timeout,
  codeSent: smsCodeSent,
  timeout: const Duration(seconds: 20),
  verificationCompleted: verificationComplete,
  verificationFailed: verificationFailed,
);

print(this.verificationId);

}

I DO see the print for the phone number (Whatever phone number is input by the user) but the output log only shows:

flutter: Creating Verification Code for: 5555555555 flutter: null

Meaning that the smsCodeSent function is never called. Any ideas why?

(Results of Flutter Doctor to follow)

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-CA) • Flutter version 1.12.13+hotfix.5 at /Users/iosdev/Developer/flutter • Framework revision 27321ebbad (3 weeks ago), 2019-12-10 18:15:01 -0800 • Engine revision 2994f7e1e6 • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/iosdev/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1) • Xcode at /applications/Xcode.app/Contents/Developer • Xcode 10.2.1, Build version 10E1001 • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 42.1.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.7.1

[✓] Connected device (1 available) • iPhone Xʀ • E901CA1F-553F-41E6-864D-57E151B3F39F • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)

Well I found out the resolution to my issue. Apparently there's an issue with iOS that it refuses to treat the simulator like a real device, and so won't properly follow the flow of actual authentication using firebase.

So for anyone who has a similar issue, ensure you're doing your firebase_auth testing on an actual device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM