Firebase 电话身份验证使之前运行的 iOS 应用程序崩溃

时间:2021-07-17 09:19:42

标签: firebase flutter dart firebase-authentication

电话号码身份验证现在会突然使应用程序崩溃。身份验证以前可以正常工作,但现在它使应用程序崩溃。 我非常确定所有设置都很好,因为之前可以正常工作,但现在对我来说很奇怪是什么导致了崩溃。

这是我的代码

Future<bool> signIn() async {
    try {
      //!here is where phone auth start
      final AuthCredential phoneCredential = PhoneAuthProvider.credential(
        verificationId: verificationId,
        smsCode: otpNumberInput.text,
      );
      final getuser =
          await (auth.currentUser?.linkWithCredential(phoneCredential));
      final user = getuser?.user;
      await firestore.collection('users').doc(user?.uid).update({
        'phoneNumber': user?.phoneNumber,
      });
      SharedPreferences pref = await SharedPreferences.getInstance();
      await pref.setBool('phoneAuth', true);
      return true;
    } catch (e) {
      return false;
    }
  }

  Future<void> phoneAuth(BuildContext context) async {
    try {
      final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
          (String verId) {
        verificationId = verId;
      };
      final PhoneCodeSent codeSent = (String verId, [int forceCodeResend]) {
        verificationId = verId;
        setState(() {
          next = false;
        });
      };
      final PhoneVerificationCompleted verificationCompleted =
          (phoneAuthCredential) {
        print('verified');
      };
      final PhoneVerificationFailed verificationFailed = (error) async {
        print('$error');
        await Flushbar(
          title: 'Error !!!',
          message: 'Error Phone Verification $error',
          duration: Duration(seconds: 3),
        ).show(context);
      };
      try {
        await FirebaseAuth.instance.verifyPhoneNumber(
          phoneNumber: number123,
          verificationCompleted: verificationCompleted,
          verificationFailed: verificationFailed,
          codeSent: codeSent,
          codeAutoRetrievalTimeout: codeAutoRetrievalTimeout,
          timeout: Duration(seconds: 5),
        );
      } catch (e) {
        print('..............from phone otp $e');
      }
    } catch (e) {
      //print('this is the error from otp $e');
      await Flushbar(
        title: 'OTP Error !!!',
        message: 'Error in OTP $e',
        duration: Duration(seconds: 3),
      ).show(context);
    }
  }

我的 info.plist

<string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.googleusercontent.apps.390....90211-klbqki2me0m8f.......</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb368586.....</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>FacebookAppID</key>
    <string>368586070589462</string>
    <key>FacebookDisplayName</key>
    <string>FaithMeetsLove</string>
    <key>FirebaseAppDelegateProxyEnabled</key>
    <false/>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbapi20160328</string>
        <string>fbauth</string>
        <string>fb-messenger-share-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>

之前所有这些都可以正常工作,但突然之间应用程序崩溃了。我不知道在哪里再看..

pubspec.ymal

name: FaithMeetsLove
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
    


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  another_flushbar:
  avatar_glow:
  age: 
  badges:
  cached_network_image:
  circular_check_box:
  cloud_firestore:
  carousel_pro_nullsafety:
  camera:
  drag_select_grid_view:
  firebase_auth:
  firebase_storage:
  firebase_messaging:
  flutter_facebook_login:
  path_drawing:
  extended_image:
  geocoder:
  flutter_tindercard:
  flutter_progress_hud:
  flutter_range_slider:
  font_awesome_flutter:
  flutter_windowmanager:
  flutter_local_notifications: 
  full_screen_image:
  flutter_holo_date_picker:
  flutter_native_image:
  google_sign_in:
  google_fonts:
  intl_phone_number_input:
  image_editor:
  image_picker:
  local_auth:
  location:
  overlay_support:
  provider:
  pin_code_text_field: 
  path_provider:
  photo_view:
  path:
  shared_preferences: ^2.0.6
  syncfusion_flutter_sliders: ^19.1.59-beta
  showcaseview:
  secure_application:
  step_progress_indicator: 
  swipe_to:
  the_apple_sign_in:
  
  

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
      - assets/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: MyFlutterApp
      fonts:
        - asset: assets/fonts/MyFlutterApp.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

0 个答案:

没有答案