메뉴로 바로가기

Firebase Google 로그인

GitHub

이 가이드는 iOS에서 Google Sign-In을 Firebase Authentication과 통합하는 데 도움이 됩니다. Firebase Google 설정을 이미 완료한 것으로 가정합니다. 일반 Firebase Google 설정을 이미 완료한 것으로 가정합니다..

설정 단계

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

    Firebase 프로젝트 개요
  2. 버튼 Add app Firebase 앱 추가 버튼

    주의 Firebase Add App 버튼
  3. 선택 iOS

    Firebase Add App iOS 버튼
  4. 폼의 첫 번째 부분을 완성하세요

    1. 폼의 Apple bundle ID
      1. Xcode에서 앱을 사용하는 npx cap open ios
      2. Xcode 프로젝트 탐색기에서 App Xcode에서 앱을 선택한 경우에만
      3. Xcode의 Targets 섹션에 있습니다. Targets -> App 선택된 앱을 선택한 경우에만
      4. Find your Bundle Identifier Xcode 프로젝트 설정에서 Bundle Identifier 필드를 찾으세요
      5. 복사하여 Bundle Identifier Firebase 콘솔에 붙여넣으세요 Firebase 앱 추가 iOS Bundle ID 필드
    2. 버튼을 클릭하세요 Register app Firebase 앱 추가 iOS 등록 버튼 Firebase Add App iOS Register Button
  5. Skip the Download config file step

    Firebase Add App iOS Skip Download Button
  6. Skip the Add firebase SDK step

    Firebase Add App iOS Skip Download Firebase SDK Button
  7. Skip the Add initialization code step

    Firebase Add App iOS Skip Add Initialization Code Button
  8. Click on the Continue to console button

    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. 프로젝트 선택자 클릭하세요. Google Cloud Console 프로젝트 선택자
      2. Firebase 프로젝트의 정확한 이름으로 프로젝트를 검색하세요. 그리고 클릭하세요. 나의 경우는 sociallogin-tutorial-app. Firebase 프로젝트 선택자 프로젝트
    3. 검색 바를 열고 credentials

      1. 검색 바를 열고 Google Cloud Console 검색 바
      2. 검색하세요. credentials 그리고 클릭하세요. APIs and Services 스크린샷의 2번에 해당하는 Google Cloud Console 인증 정보 검색
    4. 클릭하세요. iOS client for [YOUR_APP_ID] (auto created by Google Service) 1입니다. 나의 경우는 sociallogin-tutorial-app.

      Google Cloud Console 인증 iOS 클라이언트 ID
    5. 복사하세요. Client ID 그리고 iOS URL scheme이것은 각각의 iOSClientId 그리고 YOUR_DOT_REVERSED_IOS_CLIENT_ID.

      __CAPGO_KEEP_12__
  10. __CAPGO_KEEP_13__

    1. __CAPGO_KEEP_14__ Build -> Authentication __CAPGO_KEEP_15__
    2. __CAPGO_KEEP_16__ Sign-in method __CAPGO_KEEP_17__ __CAPGO_KEEP_18__
    3. Click on the Google 제공자 Firebase Authentication Sign-in Method Google Provider
    4. Click on the Web SDK configuration 버튼 Firebase Authentication Sign-in Method Web SDK Configuration Button
    5. Copy the Web client ID. 이는 플러그인의 webClientId 메소드 initialize method of the plugin. Firebase Authentication Sign-in Method Web SDK Configuration Web Client ID
  11. 앱의 Info.plist를 수정하세요

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

      Xcode 프로젝트 탐색기에서
    2. 파일을 오른쪽 클릭하고 소스 코드로 열기 code

      소스 코드로 열기 Code 옵션을 보여주는 오른쪽 클릭 메뉴
    3. 파일의 하단 부분에서 Plist 파일에서 </dict> 태그

      Info.plist 파일의 닫는 태그
    4. 닫는 태그 바로 앞에 다음 구문을 삽입하세요. </dict> URL 스키마를 포함한 Info.plist __CAPGO_KEEP_0__

      닫는 태그 바로 앞에 URL 스키마를 포함한 Info.plist code
      <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으로

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

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

  14. 변경하기 AppDelegate.swift

    1. AppDelegate.xib 파일을 열기

      Xcode 프로젝트 탐색기에서 AppDelegate.swift 파일을 열기
    2. 추가하기 import GoogleSignIn AppDelegate.swift 파일의 맨 위에 추가하기

      AppDelegate.swift 파일에 GoogleSignIn import를 추가하기
    3. 찾기 func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) 함수

      AppDelegate.swift 파일의 원래 openURL 함수를 찾기
    4. 함수를 다음처럼 변경하기

      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)
      }
      AppDelegate.swift 파일의 openURL 함수를 GoogleSignIn 처리하기
    5. 파일을 저장하세요. Command + S

  15. Google 로그인 기능을 앱에 사용하기

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

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

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

  • Firebase 웹 클라이언트 ID와 일치하는 idToken Firebase Console에서 Google Sign-In이 활성화되어 있는지 확인하세요.
  • Firebase Console에서 Google Sign-In이 활성화되어 있는지 확인하세요.
  • __CAPGO_KEEP_0__ URL 스키마와 GIDClientID가 정확한지 Info.plist를 확인하세요.
  • Verify iOSServerClientId __CAPGO_KEEP_0__ 웹 클라이언트 ID와 일치하는지 확인하세요.
  • Review the code 예시 앱을 참조하세요. for reference

Firebase Google 로그인 iOS에서 계속하기

Section titled “Firebase Google 로그인 iOS에서 계속하기”

__CAPGO_KEEP_2__이 Firebase Google 로그인 iOS를 사용하여 인증 및 계정 흐름을 계획하고 있다면 Firebase Google Login on iOS __CAPGO_KEEP_2__을 연결하세요. Using @capgo/capacitor-social-login capgo/capacitor-social-login을 사용하는 원시 기능에 대해 capgo/capacitor-social-login capgo/capacitor-social-login의 구현 세부 사항에 대해 capgo/capacitor-passkey capgo/capacitor-passkey의 구현 세부 사항에 대해 capgo/capacitor-native-biometric capgo/capacitor-native-biometric의 구현 세부 사항에 대해, 그리고 두 단계 인증 두 단계 인증의 구현 세부 사항에 대해.