[🐛] After logging out or reinstalling the app, the authorized user remains.(In iPhone 7)

Issue

I am implementing a Firebase auth module to enable phone verification in my application. I configure everything according to the documents and everything works (I get SMS). After updating to version 10.1.0 everything works fine on android and ios but when i try to check the code on iPhone 7 it finds the previous authorized user and does not let login the new user.
I don’t get any error other than invalid code.

SMS verification function:

  const clickCheckCode = async () => {
    setLoading(true);
    try {
      /** Validate code */
      setConfBtnIsDis(true);

      /** if (!isUserAuth) */
      let currentUserAuth = auth().currentUser;

      console.log(currentUserAuth);

      if (currentUserAuth === null) await confirm.confirm(value)
      else return;

      /** Get user by request */
      getUserTokenByPhone(userPhone, userCountry);

      setLoading(false);
    } catch (error) {
      Alert.alert('Error', 'Invalid code!', [{text: 'OK'}], {cancelable: true});
      setLoading(false);
    }
};

console.log(currentUserAuth) output:

Click To Expand

 { _auth: 
   { _app: 
      { _name: '[DEFAULT]',
        _deleted: false,
        _deleteApp: [Function: bound deleteApp],
        _options: 
         { projectId: 'revcicom',
           databaseURL: 'https://revcicom.firebaseio.com',
           androidClientID: '1043740910299-6nvj8lg75u6tqp731enrrlipm0on1j25.apps.googleusercontent.com',
           messagingSenderId: '1043740910299',
           appId: '1:1043740910299:ios:4529cff16eaf42b418a2fe',
           clientId: '1043740910299-q2hflvo7p37nmnga2mi6itm5kidnro2r.apps.googleusercontent.com',
           storageBucket: 'revcicom.appspot.com',
           apiKey: 'AIzaSyBoaWU_TzqLS75aKr1jZGBJsP4ITaJZQoI' },
        _automaticDataCollectionEnabled: true,
        _initialized: true,
        _nativeInitialized: true },
     _nativeModule: 
      { addAuthStateListener: [Function],
        removeAuthStateListener: [Function],
        addIdTokenListener: [Function],
        removeIdTokenListener: [Function],
        setAppVerificationDisabledForTesting: [Function],
        useUserAccessGroup: [Function],
        signOut: [Function],
        signInAnonymously: [Function],
        signInWithEmailAndPassword: [Function],
        signInWithEmailLink: [Function],
        createUserWithEmailAndPassword: [Function],
        delete: [Function],
        reload: [Function],
        sendEmailVerification: [Function],
        verifyBeforeUpdateEmail: [Function],
        updateEmail: [Function],
        updatePassword: [Function],
        updatePhoneNumber: [Function],
        updateProfile: [Function],
        getIdToken: [Function],
        getIdTokenResult: [Function],
        signInWithCredential: [Function],
        confirmPasswordReset: [Function],
        applyActionCode: [Function],
        checkActionCode: [Function],
        sendPasswordResetEmail: [Function],
        sendSignInLinkToEmail: [Function],
        signInWithCustomToken: [Function],
        signInWithPhoneNumber: [Function],
        verifyPhoneNumber: [Function],
        confirmationResultConfirm: [Function],
        linkWithCredential: [Function],
        unlink: [Function],
        reauthenticateWithCredential: [Function],
        fetchSignInMethodsForEmail: [Function],
        setLanguageCode: [Function],
        useDeviceLanguage: [Function],
        verifyPasswordResetCode: [Function],
        useEmulator: [Function],
        APP_USER: 
         { '[DEFAULT]': 
            { phoneNumber: '+380957757075',
              isAnonymous: false,
              email: null,
              refreshToken: 'AG8BCndhTNBjr7oxmQv4gbJgRgC7qmBks3oPZOCUvV5ve7Bwz6ssYS0laV_EG0T0hzrTpYryaqc0fb1J5ubodIF-GBOjIdMMLf8H-0viiXms8BQFLfYhSl2C4GspE6WKk5YlMMEXfnTdmohdAbb98U6ospUq5j2r_9DF6cGz6HIFL66evkot0IHYCph-41_WTniIiiYkkfZ4',
              metadata: { creationTime: 1602585051899, lastSignInTime: 1605170079846 },
              uid: 'vwjRU3XtpLbhtUiwAYnw6B5HpBI2',
              photoURL: null,
              providerId: 'firebase',
              emailVerified: false,
              providerData: [ { providerId: 'phone', phoneNumber: '+380957757075' } ],
              displayName: null } },
        APP_LANGUAGE: {},
        getConstants: [Function] },
     _customUrlOrRegion: undefined,
     _config: 
      { statics: 
         { AppleAuthProvider: [Function: AppleAuthProvider],
           EmailAuthProvider: [Function: EmailAuthProvider],
           PhoneAuthProvider: [Function: PhoneAuthProvider],
           GoogleAuthProvider: [Function: GoogleAuthProvider],
           GithubAuthProvider: [Function: GithubAuthProvider],
           TwitterAuthProvider: [Function: TwitterAuthProvider],
           FacebookAuthProvider: [Function: FacebookAuthProvider],
           OAuthProvider: [Function: OAuthProvider],
           PhoneAuthState: 
            { CODE_SENT: 'sent',
              AUTO_VERIFY_TIMEOUT: 'timeout',
              AUTO_VERIFIED: 'verified',
              ERROR: 'error' } },
        version: '10.1.1',
        namespace: 'auth',
        nativeModuleName: 'RNFBAuthModule',
        nativeEvents: 
         [ 'auth_state_changed',
           'auth_id_token_changed',
           'phone_auth_state_changed' ],
        hasMultiAppSupport: true,
        hasCustomUrlOrRegionSupport: false,
        ModuleClass: [Function: FirebaseAuthModule] },
     _user: [Circular],
     _settings: null,
     _authResult: true,
     _languageCode: undefined },
  _user: 
   { phoneNumber: '+380957757075',
     isAnonymous: false,
     email: null,
     refreshToken: 'AG8BCndhTNBjr7oxmQv4gbJgRgC7qmBks3oPZOCUvV5ve7Bwz6ssYS0laV_EG0T0hzrTpYryaqc0fb1J5ubodIF-GBOjIdMMLf8H-0viiXms8BQFLfYhSl2C4GspE6WKk5YlMMEXfnTdmohdAbb98U6ospUq5j2r_9DF6cGz6HIFL66evkot0IHYCph-41_WTniIiiYkkfZ4',
     metadata: { creationTime: 1602585051899, lastSignInTime: 1605170079846 },
     uid: 'vwjRU3XtpLbhtUiwAYnw6B5HpBI2',
     photoURL: null,
     providerId: 'firebase',
     emailVerified: false,
     providerData: [ { providerId: 'phone', phoneNumber: '+380957757075' } ],
     displayName: null } }

react-native info output:

System:
    OS: macOS 10.15.5
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 271.21 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.18.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.5 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 11.7/11E801a - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.13.0 => 4.13.0 
    react: ^17.0.1 => 17.0.1 
    react-native: ^0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
SMMs-MacBook-Air:mobile marketolog$ 

1 possible answer(s) on “[🐛] After logging out or reinstalling the app, the authorized user remains.(In iPhone 7)

  1. Try putting this on your AppDelegate.m:

      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        if (![defaults boolForKey:@"notFirstRun"]) {
            [defaults setBool:YES forKey:@"notFirstRun"];
            [defaults synchronize];
            [[FIRAuth auth] signOut:NULL];
       }
    
    

    put it after

      if ([FIRApp defaultApp] == nil) {
        [FIRApp configure];
      }
    
    

[🐛] After logging out or reinstalling the app, the authorized user remains.(In iPhone 7)

Issue

I am implementing a Firebase auth module to enable phone verification in my application. I configure everything according to the documents and everything works (I get SMS). After updating to version 10.1.0 everything works fine on android and ios but when i try to check the code on iPhone 7 it finds the previous authorized user and does not let login the new user.
I don’t get any error other than invalid code.

SMS verification function:

  const clickCheckCode = async () => {
    setLoading(true);
    try {
      /** Validate code */
      setConfBtnIsDis(true);

      /** if (!isUserAuth) */
      let currentUserAuth = auth().currentUser;

      console.log(currentUserAuth);

      if (currentUserAuth === null) await confirm.confirm(value)
      else return;

      /** Get user by request */
      getUserTokenByPhone(userPhone, userCountry);

      setLoading(false);
    } catch (error) {
      Alert.alert('Error', 'Invalid code!', [{text: 'OK'}], {cancelable: true});
      setLoading(false);
    }
};

console.log(currentUserAuth) output:

Click To Expand

 { _auth: 
   { _app: 
      { _name: '[DEFAULT]',
        _deleted: false,
        _deleteApp: [Function: bound deleteApp],
        _options: 
         { projectId: 'revcicom',
           databaseURL: 'https://revcicom.firebaseio.com',
           androidClientID: '1043740910299-6nvj8lg75u6tqp731enrrlipm0on1j25.apps.googleusercontent.com',
           messagingSenderId: '1043740910299',
           appId: '1:1043740910299:ios:4529cff16eaf42b418a2fe',
           clientId: '1043740910299-q2hflvo7p37nmnga2mi6itm5kidnro2r.apps.googleusercontent.com',
           storageBucket: 'revcicom.appspot.com',
           apiKey: 'AIzaSyBoaWU_TzqLS75aKr1jZGBJsP4ITaJZQoI' },
        _automaticDataCollectionEnabled: true,
        _initialized: true,
        _nativeInitialized: true },
     _nativeModule: 
      { addAuthStateListener: [Function],
        removeAuthStateListener: [Function],
        addIdTokenListener: [Function],
        removeIdTokenListener: [Function],
        setAppVerificationDisabledForTesting: [Function],
        useUserAccessGroup: [Function],
        signOut: [Function],
        signInAnonymously: [Function],
        signInWithEmailAndPassword: [Function],
        signInWithEmailLink: [Function],
        createUserWithEmailAndPassword: [Function],
        delete: [Function],
        reload: [Function],
        sendEmailVerification: [Function],
        verifyBeforeUpdateEmail: [Function],
        updateEmail: [Function],
        updatePassword: [Function],
        updatePhoneNumber: [Function],
        updateProfile: [Function],
        getIdToken: [Function],
        getIdTokenResult: [Function],
        signInWithCredential: [Function],
        confirmPasswordReset: [Function],
        applyActionCode: [Function],
        checkActionCode: [Function],
        sendPasswordResetEmail: [Function],
        sendSignInLinkToEmail: [Function],
        signInWithCustomToken: [Function],
        signInWithPhoneNumber: [Function],
        verifyPhoneNumber: [Function],
        confirmationResultConfirm: [Function],
        linkWithCredential: [Function],
        unlink: [Function],
        reauthenticateWithCredential: [Function],
        fetchSignInMethodsForEmail: [Function],
        setLanguageCode: [Function],
        useDeviceLanguage: [Function],
        verifyPasswordResetCode: [Function],
        useEmulator: [Function],
        APP_USER: 
         { '[DEFAULT]': 
            { phoneNumber: '+380957757075',
              isAnonymous: false,
              email: null,
              refreshToken: 'AG8BCndhTNBjr7oxmQv4gbJgRgC7qmBks3oPZOCUvV5ve7Bwz6ssYS0laV_EG0T0hzrTpYryaqc0fb1J5ubodIF-GBOjIdMMLf8H-0viiXms8BQFLfYhSl2C4GspE6WKk5YlMMEXfnTdmohdAbb98U6ospUq5j2r_9DF6cGz6HIFL66evkot0IHYCph-41_WTniIiiYkkfZ4',
              metadata: { creationTime: 1602585051899, lastSignInTime: 1605170079846 },
              uid: 'vwjRU3XtpLbhtUiwAYnw6B5HpBI2',
              photoURL: null,
              providerId: 'firebase',
              emailVerified: false,
              providerData: [ { providerId: 'phone', phoneNumber: '+380957757075' } ],
              displayName: null } },
        APP_LANGUAGE: {},
        getConstants: [Function] },
     _customUrlOrRegion: undefined,
     _config: 
      { statics: 
         { AppleAuthProvider: [Function: AppleAuthProvider],
           EmailAuthProvider: [Function: EmailAuthProvider],
           PhoneAuthProvider: [Function: PhoneAuthProvider],
           GoogleAuthProvider: [Function: GoogleAuthProvider],
           GithubAuthProvider: [Function: GithubAuthProvider],
           TwitterAuthProvider: [Function: TwitterAuthProvider],
           FacebookAuthProvider: [Function: FacebookAuthProvider],
           OAuthProvider: [Function: OAuthProvider],
           PhoneAuthState: 
            { CODE_SENT: 'sent',
              AUTO_VERIFY_TIMEOUT: 'timeout',
              AUTO_VERIFIED: 'verified',
              ERROR: 'error' } },
        version: '10.1.1',
        namespace: 'auth',
        nativeModuleName: 'RNFBAuthModule',
        nativeEvents: 
         [ 'auth_state_changed',
           'auth_id_token_changed',
           'phone_auth_state_changed' ],
        hasMultiAppSupport: true,
        hasCustomUrlOrRegionSupport: false,
        ModuleClass: [Function: FirebaseAuthModule] },
     _user: [Circular],
     _settings: null,
     _authResult: true,
     _languageCode: undefined },
  _user: 
   { phoneNumber: '+380957757075',
     isAnonymous: false,
     email: null,
     refreshToken: 'AG8BCndhTNBjr7oxmQv4gbJgRgC7qmBks3oPZOCUvV5ve7Bwz6ssYS0laV_EG0T0hzrTpYryaqc0fb1J5ubodIF-GBOjIdMMLf8H-0viiXms8BQFLfYhSl2C4GspE6WKk5YlMMEXfnTdmohdAbb98U6ospUq5j2r_9DF6cGz6HIFL66evkot0IHYCph-41_WTniIiiYkkfZ4',
     metadata: { creationTime: 1602585051899, lastSignInTime: 1605170079846 },
     uid: 'vwjRU3XtpLbhtUiwAYnw6B5HpBI2',
     photoURL: null,
     providerId: 'firebase',
     emailVerified: false,
     providerData: [ { providerId: 'phone', phoneNumber: '+380957757075' } ],
     displayName: null } }

react-native info output:

System:
    OS: macOS 10.15.5
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 271.21 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.18.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.5 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 11.7/11E801a - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.13.0 => 4.13.0 
    react: ^17.0.1 => 17.0.1 
    react-native: ^0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
SMMs-MacBook-Air:mobile marketolog$ 

1 possible answer(s) on “[🐛] After logging out or reinstalling the app, the authorized user remains.(In iPhone 7)

  1. Try putting this on your AppDelegate.m:

      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        if (![defaults boolForKey:@"notFirstRun"]) {
            [defaults setBool:YES forKey:@"notFirstRun"];
            [defaults synchronize];
            [[FIRAuth auth] signOut:NULL];
       }
    
    

    put it after

      if ([FIRApp defaultApp] == nil) {
        [FIRApp configure];
      }