ios – Why Firebase isAppVerificationDisabledForTesting Flag shouldn’t be working?


We’re experiencing inconsistent points with the Auth.auth().settings?.isAppVerificationDisabledForTesting = true flag in our testing surroundings. Though we preserve the SPM up to date, the error happens intermittently with none code adjustments. For this testing surroundings, we observe this firebase information.

The most recent difficulty happens throughout code verification, which returns the error proven beneath. The verification ID is nil, although we’re setting it to an empty string.

The telephone auth credential was created with an empty verification ID.

Beneath are the primary capabilities we use to register/register a consumer with a telephone quantity.

/// Known as the perform to despatched verification code
func sentVerificationCode(to telephone: String) async throws {
    // That is our testing surroundings 
    #if DEV
        Auth.auth().settings?.isAppVerificationDisabledForTesting = true
    #endif
        
    do {
       let verificationID = attempt await PhoneAuthProvider.supplier().verifyPhoneNumber(phoneNumber, uiDelegate: nil)
       UserDefaultsStorage.shared.set(key: .phoneVerificationId, string: verificationID)
       return
    } catch {
       throw error
    }
}

/// Known as to create the consumer with the verification code that was acquired
func createUser(with verificationCode: String, telephone: String) async throws {
    // 1 - Get VerificationID
    var verificationID: String? = UserDefaultsStorage.shared.getString(for: .phoneVerificationId)
    #if DEV
    // For DEV we're eradicating the verification utilizing `Auth.auth().settings?.isAppVerificationDisabledForTesting = true`. Which means that the verification code could be nil, so we have to set it to an empty string.
    verificationID = verificationID ?? ""
    #endif

    // 2 - Create credentials
    let credentials = PhoneAuthProvider.supplier().credential(withVerificationID: verificationID, verificationCode: verificationCode)
    // 3 - Register
    do {
       let consequence = attempt await Auth.auth().signIn(with: credentials)
    } catch let error {
       // Is right here the place Im receiving the error talked about above.
       throw error
    }
}

I’ve examined in a simulator and actual machine and the identical consequence.

Testing data:

  • Simulator: iPhone 16 – OS 18.1
  • Actual machine: iPhone 13 – OS 18.3.2
  • Xcode 16.3

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles