iOS์—์„œ Facebook์œผ๋กœ ์‚ฌ์šฉ์ž ๋กœ๊ทธ์ธ

Facebook ๋กœ๊ทธ์ธ ๋˜๋Š” Facebook Limited ๋กœ๊ทธ์ธ์„ ์•ฑ์— ํ†ตํ•ฉํ•˜์—ฌ ์‚ฌ์šฉ์ž๊ฐ€ Facebook ๊ณ„์ •์„ ์‚ฌ์šฉํ•˜์—ฌ Identity Platform์œผ๋กœ ์ธ์ฆํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ํŽ˜์ด์ง€์—์„œ๋Š” Identity Platform์„ ์‚ฌ์šฉํ•˜์—ฌ iOS ์•ฑ์— Facebook์œผ๋กœ ๋กœ๊ทธ์ธ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

์‹œ์ž‘ํ•˜๊ธฐ ์ „์—

  1. iOS ํ”„๋กœ์ ํŠธ์— Firebase๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

  2. Podfile์— ๋‹ค์Œ ํฌ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

    pod 'FirebaseAuth'
    
  3. Google Cloud ์ฝ˜์†”์—์„œ ID ๊ณต๊ธ‰์—…์ฒด ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

    ID ๊ณต๊ธ‰์—…์ฒด ํŽ˜์ด์ง€๋กœ ์ด๋™

  4. ๊ณต๊ธ‰์—…์ฒด ์ถ”๊ฐ€๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

  5. ๋ชฉ๋ก์—์„œ Facebook์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  6. Facebook ์•ฑ ID์™€ ์•ฑ ๋ณด์•ˆ ๋น„๋ฐ€์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ์•„์ง ID์™€ ๋ณด์•ˆ ๋น„๋ฐ€์ด ์—†์œผ๋ฉด Facebook for Developers ํŽ˜์ด์ง€์—์„œ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  7. Facebook ๊ตฌ์„ฑ ์•„๋ž˜์— ๋‚˜์—ด๋œ URI๋ฅผ ํŠธ์œ„ํ„ฐ ์•ฑ์˜ ์œ ํšจํ•œ OAuth ๋ฆฌ๋””๋ ‰์…˜ URI๋กœ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. Identity Platform์—์„œ ์ปค์Šคํ…€ ๋„๋ฉ”์ธ์„ ๊ตฌ์„ฑํ•œ ๊ฒฝ์šฐ ๊ธฐ๋ณธ ๋„๋ฉ”์ธ ๋Œ€์‹  ์ปค์Šคํ…€ ๋„๋ฉ”์ธ์„ ์‚ฌ์šฉํ•˜๋„๋ก Facebook ์•ฑ ๊ตฌ์„ฑ์˜ ๋ฆฌ๋””๋ ‰์…˜ URI๋ฅผ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด https://myproject.firebaseapp.com/__/auth/handler๋ฅผ https://auth.myownpersonaldomain.com/__/auth/handler๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

  8. ์Šน์ธ๋œ ๋„๋ฉ”์ธ ์•„๋ž˜์˜ ๋„๋ฉ”์ธ ์ถ”๊ฐ€๋ฅผ ํด๋ฆญํ•˜์—ฌ ์•ฑ์˜ ๋„๋ฉ”์ธ์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ ์šฉ๋„๋กœ๋Š” localhost๊ฐ€ ์ด๋ฏธ ๊ธฐ๋ณธ์ ์œผ๋กœ ์‚ฌ์šฉ ์„ค์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

  9. ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌ์„ฑ์—์„œ ์„ค์ • ์„ธ๋ถ€์ •๋ณด๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. ์Šค๋‹ˆํŽซ์„ ์•ฑ ์ฝ”๋“œ์— ๋ณต์‚ฌํ•˜์—ฌ Identity Platform ํด๋ผ์ด์–ธํŠธ SDK๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค.

  10. ์ €์žฅ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

Facebook ๋กœ๊ทธ์ธ ๊ตฌํ˜„

'๊ธฐ๋ณธ' Facebook ๋กœ๊ทธ์ธ์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ์™„๋ฃŒํ•˜์„ธ์š”. ๋˜๋Š” ๋‹ค์Œ ์„น์…˜์—์„œ์™€ ๊ฐ™์ด Facebook Limited ๋กœ๊ทธ์ธ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  1. ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด ์•ฑ์— Facebook ์ธ์ฆ์„ ํ†ตํ•ฉํ•ฉ๋‹ˆ๋‹ค. FBSDKLoginButton ๊ฐ์ฒด๋ฅผ ์ดˆ๊ธฐํ™”ํ•  ๋•Œ ๋กœ๊ทธ์ธ ๋ฐ ๋กœ๊ทธ์•„์›ƒ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์„ ๋Œ€๋ฆฌ์ž๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    Swift

    let loginButton = FBSDKLoginButton()
    loginButton.delegate = self

    Objective-C

    FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.delegate = self;
    ๋Œ€๋ฆฌ์ž์—์„œ didCompleteWithResult:error:๋ฅผ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

    Swift

    func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
      if let error = error {
        print(error.localizedDescription)
        return
      }
      // ...
    }

    Objective-C

    - (void)loginButton:(FBSDKLoginButton *)loginButton
        didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
                        error:(NSError *)error {
      if (error == nil) {
        // ...
      } else {
        NSLog(error.localizedDescription);
      }
    }
  2. UIApplicationDelegate์—์„œ Firebase ๋ชจ๋“ˆ์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.

    Swift

    import FirebaseCore
    import FirebaseAuth
          

    Objective-C

    @import FirebaseCore;
    @import FirebaseAuth;
          
  3. ์ผ๋ฐ˜์ ์œผ๋กœ ์•ฑ์˜ application:didFinishLaunchingWithOptions: ๋ฉ”์„œ๋“œ์—์„œ FirebaseApp ๊ณต์œ  ์ธ์Šคํ„ด์Šค๋ฅผ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

    Swift

    // Use Firebase library to configure APIs
    FirebaseApp.configure()

    Objective-C

    // Use Firebase library to configure APIs
    [FIRApp configure];
  4. ์‚ฌ์šฉ์ž๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ๋กœ๊ทธ์ธํ•˜๋ฉด didCompleteWithResult:error: ๊ตฌํ˜„์—์„œ ๋กœ๊ทธ์ธํ•œ ์‚ฌ์šฉ์ž์˜ ์•ก์„ธ์Šค ํ† ํฐ์„ ๊ฐ€์ ธ์™€์„œ Identity Platform ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋กœ ๊ตํ™˜ํ•ฉ๋‹ˆ๋‹ค.

    Swift

    let credential = FacebookAuthProvider
      .credential(withAccessToken: AccessToken.current!.tokenString)

    Objective-C

    FIRAuthCredential *credential = [FIRFacebookAuthProvider
        credentialWithAccessToken:[FBSDKAccessToken currentAccessToken].tokenString];

Facebook Limited ๋กœ๊ทธ์ธ ๊ตฌํ˜„

'๊ธฐ๋ณธ' Facebook ๋กœ๊ทธ์ธ ๋Œ€์‹  Facebook Limited ๋กœ๊ทธ์ธ์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ์™„๋ฃŒํ•˜์„ธ์š”.

  1. ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด ์•ฑ์— Facebook Limited ๋กœ๊ทธ์ธ์„ ํ†ตํ•ฉํ•ฉ๋‹ˆ๋‹ค.
  2. ๋กœ๊ทธ์ธ ์š”์ฒญ๋งˆ๋‹ค ๊ณ ์œ ํ•œ ์ž„์˜ ๋ฌธ์ž์—ด์ธ 'nonce'๊ฐ€ ์ƒ์„ฑ๋˜๋ฉฐ ์ด ๋ฌธ์ž์—ด์€ ์•ฑ์˜ ์ธ์ฆ ์š”์ฒญ์— ๋Œ€ํ•œ ์‘๋‹ต์œผ๋กœ ID ํ† ํฐ์ด ๋ช…์‹œ์ ์œผ๋กœ ๋ถ€์—ฌ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋ฆด๋ ˆ์ด ๊ณต๊ฒฉ์„ ๋ฐฉ์ง€ํ•˜๋ ค๋ฉด ์ด ๋‹จ๊ณ„๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์˜ˆ์‹œ์—์„œ์™€ ๊ฐ™์ด iOS์—์„œ SecRandomCopyBytes(_:_:_)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•”ํ˜ธ๋กœ ๋ณดํ˜ธ๋œ nonce๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    Swift

    private func randomNonceString(length: Int = 32) -> String {
      precondition(length > 0)
      var randomBytes = [UInt8](repeating: 0, count: length)
      let errorCode = SecRandomCopyBytes(kSecRandomDefault, randomBytes.count, &randomBytes)
      if errorCode != errSecSuccess {
        fatalError(
          "Unable to generate nonce. SecRandomCopyBytes failed with OSStatus \(errorCode)"
        )
      }
    
      let charset: [Character] =
        Array("0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._")
    
      let nonce = randomBytes.map { byte in
        // Pick a random character from the set, wrapping around if needed.
        charset[Int(byte) % charset.count]
      }
    
      return String(nonce)
    }
    
            

    Objective-C

    // Adapted from https://auth0.com/docs/api-auth/tutorials/nonce#generate-a-cryptographically-random-nonce
    - (NSString *)randomNonce:(NSInteger)length {
      NSAssert(length > 0, @"Expected nonce to have positive length");
      NSString *characterSet = @"0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._";
      NSMutableString *result = [NSMutableString string];
      NSInteger remainingLength = length;
    
      while (remainingLength > 0) {
        NSMutableArray *randoms = [NSMutableArray arrayWithCapacity:16];
        for (NSInteger i = 0; i < 16; i++) {
          uint8_t random = 0;
          int errorCode = SecRandomCopyBytes(kSecRandomDefault, 1, &random);
          NSAssert(errorCode == errSecSuccess, @"Unable to generate nonce: OSStatus %i", errorCode);
    
          [randoms addObject:@(random)];
        }
    
        for (NSNumber *random in randoms) {
          if (remainingLength == 0) {
            break;
          }
    
          if (random.unsignedIntValue < characterSet.length) {
            unichar character = [characterSet characterAtIndex:random.unsignedIntValue];
            [result appendFormat:@"%C", character];
            remainingLength--;
          }
        }
      }
    
      return [result copy];
    }
            
    ๋กœ๊ทธ์ธ ์š”์ฒญ๊ณผ ํ•จ๊ป˜ nonce์˜ SHA-256 ํ•ด์‹œ๋ฅผ ์ „์†กํ•˜๋ฉด Facebook์€ ์ด์— ๋Œ€ํ•œ ์‘๋‹ต์œผ๋กœ ์›๋ž˜์˜ ๊ฐ’์„ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. Identity Platform์€ ์›๋ž˜์˜ nonce๋ฅผ ํ•ด์‹ฑํ•˜๊ณ  Facebook์—์„œ ์ „๋‹ฌํ•œ ๊ฐ’๊ณผ ๋น„๊ตํ•˜์—ฌ ์‘๋‹ต์„ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค.

    Swift

    @available(iOS 13, *)
    private func sha256(_ input: String) -> String {
      let inputData = Data(input.utf8)
      let hashedData = SHA256.hash(data: inputData)
      let hashString = hashedData.compactMap {
        String(format: "%02x", $0)
      }.joined()
    
      return hashString
    }
    
            

    Objective-C

    - (NSString *)stringBySha256HashingString:(NSString *)input {
      const char *string = [input UTF8String];
      unsigned char result[CC_SHA256_DIGEST_LENGTH];
      CC_SHA256(string, (CC_LONG)strlen(string), result);
    
      NSMutableString *hashed = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH * 2];
      for (NSInteger i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) {
        [hashed appendFormat:@"%02x", result[i]];
      }
      return hashed;
    }
            
  3. FBSDKLoginButton์„ ์„ค์ •ํ•  ๋•Œ ๋กœ๊ทธ์ธ ๋ฐ ๋กœ๊ทธ์•„์›ƒ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์„ ๋Œ€๋ฆฌ์ธ์„ ์„ค์ •ํ•˜๊ณ  ์ถ”์  ๋ชจ๋“œ๋ฅผ FBSDKLoginTrackingLimited๋กœ ์„ค์ •ํ•œ ๋‹ค์Œ nonce๋ฅผ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    Swift

    func setupLoginButton() {
        let nonce = randomNonceString()
        currentNonce = nonce
        loginButton.delegate = self
        loginButton.loginTracking = .limited
        loginButton.nonce = sha256(nonce)
    }
            

    Objective-C

    - (void)setupLoginButton {
      NSString *nonce = [self randomNonce:32];
      self.currentNonce = nonce;
      self.loginButton.delegate = self;
      self.loginButton.loginTracking = FBSDKLoginTrackingLimited
      self.loginButton.nonce = [self stringBySha256HashingString:nonce];
    }
            
    ๋Œ€๋ฆฌ์ž์—์„œ didCompleteWithResult:error:๋ฅผ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

    Swift

    func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
      if let error = error {
        print(error.localizedDescription)
        return
      }
      // ...
    }
            

    Objective-C

    - (void)loginButton:(FBSDKLoginButton *)loginButton
        didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
                        error:(NSError *)error {
      if (error == nil) {
        // ...
      } else {
        NSLog(error.localizedDescription);
      }
    }
            
  4. UIApplicationDelegate์—์„œ Firebase ๋ชจ๋“ˆ์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.

    Swift

    import Firebase

    Objective-C

    @import Firebase;
  5. ์ผ๋ฐ˜์ ์œผ๋กœ ์•ฑ์˜ application:didFinishLaunchingWithOptions: ๋ฉ”์„œ๋“œ์—์„œ FirebaseApp ๊ณต์œ  ์ธ์Šคํ„ด์Šค๋ฅผ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

    Swift

    // Use Firebase library to configure APIs
    FirebaseApp.configure()

    Objective-C

    // Use Firebase library to configure APIs
    [FIRApp configure];
  6. ์‚ฌ์šฉ์ž๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ๋กœ๊ทธ์ธํ•˜๋ฉด didCompleteWithResult:error: ๊ตฌํ˜„์—์„œ ํ•ด์‹œ๋˜์ง€ ์•Š์€ nonce๊ฐ€ ํฌํ•จ๋œ Facebook์˜ ์‘๋‹ต์—์„œ ID ํ† ํฐ์„ ์‚ฌ์šฉํ•˜์—ฌ Identity Platform ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.

    Swift

    // Initialize an Identity Platform credential.
    let idTokenString = AuthenticationToken.current?.tokenString
    let nonce = currentNonce
    let credential = OAuthProvider.credential(withProviderID: "facebook.com",
                                              IDToken: idTokenString,
                                              rawNonce: nonce)
            

    Objective-C

    // Initialize an Identity Platform credential.
    NSString *idTokenString = FBSDKAuthenticationToken.currentAuthenticationToken.tokenString;
    NSString *rawNonce = self.currentNonce;
    FIROAuthCredential *credential = [FIROAuthProvider credentialWithProviderID:@"facebook.com"
                                                                        IDToken:idTokenString
                                                                       rawNonce:rawNonce];
            

Identity Platform์œผ๋กœ ์ธ์ฆ

๋งˆ์ง€๋ง‰์œผ๋กœ Identity Platform ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Identity Platform์œผ๋กœ ์ธ์ฆํ•ฉ๋‹ˆ๋‹ค.

Swift

Auth.auth().signIn(with: credential) { authResult, error in
    if let error = error {
      let authError = error as NSError
      if isMFAEnabled, authError.code == AuthErrorCode.secondFactorRequired.rawValue {
        // The user is a multi-factor user. Second factor challenge is required.
        let resolver = authError
          .userInfo[AuthErrorUserInfoMultiFactorResolverKey] as! MultiFactorResolver
        var displayNameString = ""
        for tmpFactorInfo in resolver.hints {
          displayNameString += tmpFactorInfo.displayName ?? ""
          displayNameString += " "
        }
        self.showTextInputPrompt(
          withMessage: "Select factor to sign in\n\(displayNameString)",
          completionBlock: { userPressedOK, displayName in
            var selectedHint: PhoneMultiFactorInfo?
            for tmpFactorInfo in resolver.hints {
              if displayName == tmpFactorInfo.displayName {
                selectedHint = tmpFactorInfo as? PhoneMultiFactorInfo
              }
            }
            PhoneAuthProvider.provider()
              .verifyPhoneNumber(with: selectedHint!, uiDelegate: nil,
                                 multiFactorSession: resolver
                                   .session) { verificationID, error in
                if error != nil {
                  print(
                    "Multi factor start sign in failed. Error: \(error.debugDescription)"
                  )
                } else {
                  self.showTextInputPrompt(
                    withMessage: "Verification code for \(selectedHint?.displayName ?? "")",
                    completionBlock: { userPressedOK, verificationCode in
                      let credential: PhoneAuthCredential? = PhoneAuthProvider.provider()
                        .credential(withVerificationID: verificationID!,
                                    verificationCode: verificationCode!)
                      let assertion: MultiFactorAssertion? = PhoneMultiFactorGenerator
                        .assertion(with: credential!)
                      resolver.resolveSignIn(with: assertion!) { authResult, error in
                        if error != nil {
                          print(
                            "Multi factor finanlize sign in failed. Error: \(error.debugDescription)"
                          )
                        } else {
                          self.navigationController?.popViewController(animated: true)
                        }
                      }
                    }
                  )
                }
              }
          }
        )
      } else {
        self.showMessagePrompt(error.localizedDescription)
        return
      }
      // ...
      return
    }
    // User is signed in
    // ...
}
    

Objective-C

[[FIRAuth auth] signInWithCredential:credential
                          completion:^(FIRAuthDataResult * _Nullable authResult,
                                       NSError * _Nullable error) {
    if (isMFAEnabled && error && error.code == FIRAuthErrorCodeSecondFactorRequired) {
      FIRMultiFactorResolver *resolver = error.userInfo[FIRAuthErrorUserInfoMultiFactorResolverKey];
      NSMutableString *displayNameString = [NSMutableString string];
      for (FIRMultiFactorInfo *tmpFactorInfo in resolver.hints) {
        [displayNameString appendString:tmpFactorInfo.displayName];
        [displayNameString appendString:@" "];
      }
      [self showTextInputPromptWithMessage:[NSString stringWithFormat:@"Select factor to sign in\n%@", displayNameString]
                           completionBlock:^(BOOL userPressedOK, NSString *_Nullable displayName) {
       FIRPhoneMultiFactorInfo* selectedHint;
       for (FIRMultiFactorInfo *tmpFactorInfo in resolver.hints) {
         if ([displayName isEqualToString:tmpFactorInfo.displayName]) {
           selectedHint = (FIRPhoneMultiFactorInfo *)tmpFactorInfo;
         }
       }
       [FIRPhoneAuthProvider.provider
        verifyPhoneNumberWithMultiFactorInfo:selectedHint
        UIDelegate:nil
        multiFactorSession:resolver.session
        completion:^(NSString * _Nullable verificationID, NSError * _Nullable error) {
          if (error) {
            [self showMessagePrompt:error.localizedDescription];
          } else {
            [self showTextInputPromptWithMessage:[NSString stringWithFormat:@"Verification code for %@", selectedHint.displayName]
                                 completionBlock:^(BOOL userPressedOK, NSString *_Nullable verificationCode) {
             FIRPhoneAuthCredential *credential =
                 [[FIRPhoneAuthProvider provider] credentialWithVerificationID:verificationID
                                                              verificationCode:verificationCode];
             FIRMultiFactorAssertion *assertion = [FIRPhoneMultiFactorGenerator assertionWithCredential:credential];
             [resolver resolveSignInWithAssertion:assertion completion:^(FIRAuthDataResult * _Nullable authResult, NSError * _Nullable error) {
               if (error) {
                 [self showMessagePrompt:error.localizedDescription];
               } else {
                 NSLog(@"Multi factor finanlize sign in succeeded.");
               }
             }];
           }];
          }
        }];
     }];
    }
  else if (error) {
    // ...
    return;
  }
  // User successfully signed in. Get user data from the FIRUser object
  if (authResult == nil) { return; }
  FIRUser *user = authResult.user;
  // ...
}];
    

๋‹ค์Œ ๋‹จ๊ณ„