Skip to content

iOS에서 Firebase Google 로그인

GitHub

이 안내서에서는 iOS에서 Google Sign-In을 Firebase Authentication과 통합하는 방법을 설명합니다. iOS 앱을 Firebase Console에 등록한 경우를 가정합니다. 일반적인 Firebase Google 설정을 완료한 것으로 가정합니다..

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

    파이어베이스 프로젝트 개요
  2. 버튼을 클릭하세요. Add app 버튼

    파이어베이스 앱 추가 버튼 파이어베이스 앱 추가 버튼
  3. 선택하세요. iOS

    파이어베이스 앱 추가 iOS 버튼
  4. 첫 번째 양식을 완성하세요

    1. 첫 번째 Apple bundle ID
      1. 앱을 사용하는 Xcode를 열어주세요 npx cap open ios
      2. Xcode 프로젝트 탐색기에서 App App 목표를 두 번 클릭하세요
      3. App이 선택된 Xcode의 Targets 섹션에 있습니다 Targets -> App Xcode 프로젝트 설정에서
      4. Bundle Identifier field를 찾으세요 Bundle Identifier 주의
      5. Copy the Bundle Identifier 그리고 Firebase 콘솔에 붙여넣기 Firebase Add App iOS Bundle ID Field
    2. 버튼을 클릭하세요. Register app 버튼 Firebase Add App iOS Register Button
  5. 스텝을 건너 뛰세요. Download config file Firebase Add App iOS Skip Download Button

    스텝을 건너 뛰세요.
  6. step Add firebase SDK step

    iOS Firebase 추가 앱 건너뛰기 다운로드 iOS Firebase SDK 버튼
  7. 단계 건너뛰기 Add initialization code iOS Firebase 추가 앱 건너뛰기 초기화 __CAPGO_KEEP_0__ 버튼

    Firebase Add App iOS Skip Add Initialization Code Button
  8. iOS Firebase 추가 앱 건너뛰기 버튼 Continue to console iOS Firebase 추가 앱 건너뛰기 콘솔로 계속

    iOS 클라이언트 ID와
  9. Google Cloud Console로 이동 YOUR_DOT_REVERSED_IOS_CLIENT_ID

    1. console.cloud.google.com 프로젝트 찾기

    2. 프로젝트 선택자 클릭

      1. iOS Firebase 추가 앱 건너뛰기 Google Cloud Console Project 선택기
      2. Firebase 프로젝트의 정확한 이름을 검색하여 클릭하세요. 나의 경우는 sociallogin-tutorial-app. Firebase Project 선택기 프로젝트
    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) 하나. 나의 경우는 sociallogin-tutorial-app.

      구글 클라우드 콘솔 인증 정보 iOS 클라이언트 ID
    5. __CAPGO_KEEP_0__을 복사하세요. Client ID __CAPGO_KEEP_1__도 복사하세요. iOS URL scheme. 이 각각은 당신의 __CAPGO_KEEP_2__ iOSClientId __CAPGO_KEEP_3__ YOUR_DOT_REVERSED_IOS_CLIENT_ID.

      Google Cloud Console 인증 정보 iOS Client ID 복사
  10. 웹 클라이언트 ID를 가져오세요

    1. Firebase 콘솔로 돌아가서 Build -> Authentication Firebase 인증 메뉴
    2. 버튼 클릭 Sign-in method Firebase 인증 로그인 방법 버튼 로그인 방법 버튼 클릭
    3. 제공자 클릭 Google Firebase 인증 로그인 방법 Google 제공자 로그인 방법 버튼 클릭
    4. 버튼 클릭 Web SDK configuration Firebase 콘솔로 돌아가서 Firebase 인증 Sign-in 방법 Web SDK 설정 버튼
    5. 복사하세요. 이가 당신의 Web client IDFirebase 인증 Sign-in 방법 Web __CAPGO_KEEP_0__ 설정 Web Client ID webClientId 앱의 Info.plist를 수정하세요. initialize Xcode를 열고 Firebase Authentication Sign-in Method Web SDK Configuration Web Client ID
  11. Xcode 프로젝트 탐색기에서 Info.plist 파일을 찾으세요.

    1. 이 파일을 오른쪽 클릭하고 소스 __CAPGO_KEEP_0__로 열으세요. Info.plist 소스 __CAPGO_KEEP_0__로 열기 옵션을 보여주는 오른쪽 클릭 메뉴

      소스 __CAPGO_KEEP_0__로 열기 옵션
    2. 소스 code로 열기 옵션

      소스 Code로 열기 옵션
    3. 파일의 하단에서 Plist 태그를 찾을 수 있습니다. </dict> 태그

      Info.plist 파일의 닫는 딕셔너리 태그
    4. 닫는 딕셔너리 태그 바로 앞에 다음 프래그먼트를 삽입하세요. </dict> URL 스키마 __CAPGO_KEEP_0__이 실제로 닫는 딕셔너리 태그에 삽입된 Info.plist

      Info.plist with URL schemes code inserted before closing dict tag
      <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. URL 스키마에 실제로 역전된 클라이언트 ID가 삽입된 Info.plist YOUR_DOT_REVERSED_IOS_CLIENT_ID 주의: 클라이언트 ID를 역전한 후에 URL 스키마에 삽입해야 합니다.

      URL 스키마에 실제로 역전된 클라이언트 ID가 삽입된 Info.plist
  12. YOUR_IOS_CLIENT_ID iOS Client ID를 9번 단계에서 복사한 것을

  13. 파일을 Command + S

  14. 수정 AppDelegate.swift

    1. AppDelegate를

      AppDelegate.swift 파일을 Xcode 프로젝트 탐색기에서 열기
    2. 위에 import GoogleSignIn 삽입

      AppDelegate.swift에 GoogleSignIn import를 추가했습니다.
    3. 찾아보세요. func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) 함수

      AppDelegate의 원래 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)
      }
      GoogleSignIn 처리를 포함한 수정된 앱 openURL 함수
    5. 파일을 Command + S

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

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

The user will be automatically created in Firebase Auth on first sign-in

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

  • 인증 대상이 Firebase 웹 클라이언트 ID와 일치하는지 확인하십시오. idToken Firebase 콘솔에서 Google Sign-In이 활성화되어 있는지 확인하십시오.
  • Info.plist에서 올바른 URL 스키마와 GIDClientID가 설정되어 있는지 확인하십시오.
  • 인증 대상이 웹 클라이언트 ID와 일치하는지 확인하십시오.
  • 예시 앱 __CAPGO_KEEP_0__ iOSServerClientId Verify the audience matches your Firebase web client ID
  • Check that Google Sign-In is enabled in Firebase Console example app code for reference

iOS에서 Firebase Google Login을 계속 진행하세요

iOS에서 Firebase Google Login을 계속 진행하세요

iOS에서 Firebase Google Login을 사용 중이라면 iOS에서 Firebase Google Login을 사용 중이라면 Firebase Google Login을 사용하여 인증 및 계정 흐름을 계획하고 @capgo/capacitor-social-login을 사용하여 iOS에서 Firebase Google Login과 연결하세요 @capgo/capacitor-social-login을 사용하여 iOS에서 Firebase Google Login의 네이티브 기능을 구현하세요 @capgo/capacitor-social-login을 사용하여 iOS에서 Firebase Google Login의 구현 세부 정보를 확인하세요 @capgo/capacitor-passkey을 사용하여 iOS에서 Firebase Google Login의 구현 세부 정보를 확인하세요 @capgo/capacitor-passkey을 사용하여 iOS에서 Firebase Google Login의 구현 세부 정보를 확인하세요 @capgo/capacitor-passkey을 사용하여 iOS에서 Firebase Google Login의 구현 세부 정보를 확인하세요 @capgo/capacitor-native-생체인식 for the implementation detail in @capgo/capacitor-native-생체인식, and 두 단계 인증 for the implementation detail in 두 단계 인증.