내용으로 건너뛰기

Firebase Google 로그인 iOS

GitHub

이 가이드는 iOS에서 Google Sign-In을 Firebase Authentication과 통합하는 데 도움이 될 것입니다. iOS에서 Google Sign-In을 Firebase Authentication과 통합하는 데 도움이 될 것입니다. __CAPGO_KEEP_0__ 설정.

설정 단계

설정 단계
  1. 프로젝트 개요로 이동하세요. console.cloud.google.com

    Firebase 프로젝트 개요
  2. 버튼을 클릭하세요. Add app Firebase 앱 추가 버튼

    Firebase 앱 추가 버튼 Firebase Add App 버튼
  3. 선택 iOS

    Firebase Add App iOS 버튼
  4. 폼의 첫 번째 부분을 채우세요

    1. Fill the Apple bundle ID
      1. Xcode에서 앱을 사용하는 npx cap open ios
      2. Double click on App Xcode 프로젝트 내비게이터의 App target
      3. 앱이 올바르게 설정되어 있는지 확인하세요 Targets -> App Xcode에서 App이 선택된 Targets 섹션
      4. Find your Bundle Identifier Xcode 프로젝트 설정에서 Bundle Identifier 필드
      5. 복사하고 Bundle Identifier Firebase 콘솔에 붙여 넣으세요 Firebase Add App iOS Bundle ID 필드
    2. 버튼을 클릭하세요 Register app 버튼을 클릭하세요 iOS Firebase App 등록 버튼
  5. Firebase Skip Download config file 단계

    iOS Firebase App 다운로드 Skip 버튼
  6. Firebase Skip Add firebase SDK 단계

    iOS Firebase App 다운로드 Skip Firebase SDK 버튼
  7. Firebase Skip Add initialization code 단계

    Firebase Add App iOS Skip Add Initialization Code Button
  8. __CAPGO_KEEP_0__ 버튼 클릭하기 Continue to console 단계

    Firebase Add App iOS Continue to Console Button
  9. iOS 클라이언트 ID와 YOUR_DOT_REVERSED_IOS_CLIENT_ID

    1. Google Cloud Console로 이동하세요. console.cloud.google.com

    2. 프로젝트 찾기

      1. 프로젝트 선택기 Firebase 프로젝트 이름과 정확히 일치하는 이름으로 프로젝트를 찾으세요. 나의 경우
      2. Firebase 프로젝트 선택기 프로젝트 sociallogin-tutorial-app. 검색 바를 열고
    3. 검색 바를 열어 credentials

      1. Google Cloud Console 검색 바 __CAPGO_KEEP_0__
      2. __CAPGO_KEEP_0__ credentials __CAPGO_KEEP_1__ APIs and Services __CAPGO_KEEP_2__ __CAPGO_KEEP_3__
    4. __CAPGO_KEEP_4__ iOS client for [YOUR_APP_ID] (auto created by Google Service) __CAPGO_KEEP_5__ sociallogin-tutorial-app.

      __CAPGO_KEEP_6__
    5. __CAPGO_KEEP_7__ Client ID __CAPGO_KEEP_8__ iOS URL scheme__CAPGO_KEEP_9__ iOSClientId __CAPGO_KEEP_10__ YOUR_DOT_REVERSED_IOS_CLIENT_ID.

      Google Cloud Console에서
  10. 웹 클라이언트 ID를 가져오세요

    1. Firebase 콘솔로 돌아가서 Build -> Authentication Firebase 인증 메뉴로 이동하세요
    2. 버튼을 클릭하세요 Sign-in method __CAPGO_KEEP_0__ Firebase Authentication Sign-in Method Button
    3. Click on the Google provider Firebase Authentication Sign-in Method Google Provider
    4. Click on the Web SDK configuration button Firebase Authentication Sign-in Method Web SDK Configuration Button
    5. Copy the Web client ID. 이 설정은 플러그인에 사용할 webClientId Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ Configuration initialize Web Client ID Firebase Authentication Sign-in Method Web SDK Configuration Web Client ID
  11. 앱의 Info.plist을 수정하세요

    1. Xcode를 열고 프로젝트 탐색기에서 Info.plist 파일

      Xcode 프로젝트 탐색기에서 Info.plist 파일을 찾으세요
    2. 이 파일을 오른쪽 클릭하고 소스 code로 열기

      Info.plist 파일의 오른쪽 클릭 메뉴에서 Open As Source Code 옵션
    3. 파일의 하단 부분에서 Plist 파일에서 </dict> 태그

      Info.plist 파일의 닫는 dict 태그
    4. 닫는 태그 바로 앞에 다음 구문을 삽입하세요 </dict> 닫는 태그 바로 앞에 다음 구문을 삽입하세요

      URL schemes code을 Info.plist에 삽입하기 전에 닫는 dict 태그
      <key>CFBundleURLTypes</key>
      <array>
      <dict>
      <key>CFBundleURLSchemes</key>
      <array>
      <string>YOUR_DOT_REVERSED_IOS_CLIENT_ID</string>
      </array>
      </dict>
      </array>
      <key>GIDClientID</key>
      <string>YOUR_IOS_CLIENT_ID.apps.googleusercontent.com</string>
    5. 변경 YOUR_DOT_REVERSED_IOS_CLIENT_ID 9번 단계에서 복사한 iOS URL scheme으로 설정

      URL schemes에 실제 역전된 클라이언트 ID를 삽입한 Info.plist
  12. 변경 YOUR_IOS_CLIENT_ID 9번 단계에서 복사한 iOS Client ID로 설정

  13. __CAPGO_KEEP_0__ 파일을 저장하세요. Command + S

  14. __CAPGO_KEEP_1__을 수정하세요. AppDelegate.swift

    1. AppDelegate를 열어보세요.

      Xcode 프로젝트 내비게이터에서 AppDelegate.swift 파일을 열어보세요.
    2. __CAPGO_KEEP_2__을 삽입하세요. import GoogleSignIn AppDelegate.swift 파일의 맨 위에 __CAPGO_KEEP_3__을 추가하세요.

      GoogleSignIn import를 추가한 AppDelegate.swift 파일을 열어보세요.
    3. __CAPGO_KEEP_4__을 찾으세요. func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) __CAPGO_KEEP_5__을 찾으세요.

      AppDelegate의 원래 openURL 함수를 찾으세요.
    4. __CAPGO_KEEP_6__을 수정하세요.

      func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
      // Called when the app was launched with a url. Feel free to add additional processing here,
      // but if you want the App API to support tracking app url opens, make sure to keep this call
      var handled: Bool
      handled = GIDSignIn.sharedInstance.handle(url)
      if handled {
      return true
      }
      return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
      }
      GoogleSignIn을 처리하는 수정된 애플리케이션 openURL 함수
    5. __CAPGO_KEEP_0__으로 파일을 저장하세요. Command + S

  15. 앱에서 Google 로그인을 사용하는 방법

    이 단계에서는 앱에서 Google 로그인을 사용할 준비가 되었습니다. Google 로그인을 사용하려면 authUtils.ts 예제 앱의 인증을 위해 Google과 인증하는 파일입니다.

사용자가 Firebase Auth에 처음 로그인할 때 자동으로 사용자 계정이 생성됩니다.

인증이 지연되거나 실패하는 경우:

  • Firebase 웹 클라이언트 ID와 일치하는지 확인하세요. idToken Verify the audience matches your Firebase web client ID
  • Google Sign-In이 Firebase Console에서 활성화되어 있는지 확인하세요.
  • Info.plist에 올바른 URL schemes과 GIDClientID가 포함되어 있는지 확인하세요.
  • Verify iOSServerClientId 웹 클라이언트 ID와 일치하는지 확인하세요.
  • 참고로 __CAPGO_KEEP_0__ 예제 앱을 확인하세요. example app code iOS Firebase Google Login에서 계속 진행하세요.

Firebase Google Login on iOS를 사용하여 인증 및 계정 흐름을 계획하고 있습니다.

Firebase Google Login on iOS와 연결하세요.

Firebase Google Login on iOS와 연결하세요. Firebase Google Login on iOS와 연결하세요. Firebase Google Login on iOS와 연결하세요. @capgo/capacitor-social-login Using @capgo/capacitor-social-login @capgo/capacitor-social-login Using @capgo/capacitor-social-login @capgo/capacitor-passkey Using @capgo/capacitor-passkey @capgo/capacitor-native-biometric Using @capgo/capacitor-native-biometric Two-factor authentication Two-factor authentication