내용으로 건너뛰기

iOS에서 Firebase Google 로그인

GitHub

이 가이드는 iOS에서 Google Sign-In을 Firebase 인증과 통합하는 방법을 설명합니다. iOS 앱을 Firebase 콘솔에 등록한 경우에만 이 가이드를 따르세요. 일반 Firebase Google 설정.

  1. 프로젝트 개요를 확인하려면 console.cloud.google.com으로 이동하세요. console.cloud.google.com

    Firebase 프로젝트 개요
  2. Firebase Console에서 Add app 버튼

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

    Firebase 앱 추가 iOS 버튼
  4. 폼의 첫 번째 부분을 입력하세요

    1. 두 번째 부분을 입력하세요 Apple bundle ID
      1. Xcode를 앱이 사용하는 곳에서 열어 주세요. npx cap open ios
      2. Xcode에서 App Xcode 프로젝트 탐색기에서 앱 목표를 두 번 클릭하세요.
      3. Xcode 프로젝트 탐색기에서 앱이 선택된 상태로 Targets -> App Xcode에서 목표 섹션에 있습니다.
      4. 프로젝트 설정에서 Bundle Identifier Bundle Identifier 필드를 찾으세요.
      5. ID를 복사하세요. Bundle Identifier 그것을 Firebase 콘솔에 붙여넣으세요 Firebase Add App iOS Bundle ID 필드
    2. Firebase 콘솔에서 Register app 버튼 Firebase Add App iOS 등록 버튼
  5. 스키핑 Download config file 단계

    Firebase Add App iOS 다운로드를 건너 뛸 버튼
  6. 스키핑 Add firebase SDK 단계

    Firebase Add App iOS Firebase SDK 다운로드를 건너 뛸 버튼
  7. 스키핑 Add initialization code 단계

    파이어베이스 앱 추가 iOS Skip Add 초기화 Code 버튼
  8. 클릭하여 Continue to console 버튼

    파이어베이스 앱 추가 iOS 콘솔로 계속 버튼
  9. iOS 클라이언트 ID와 YOUR_DOT_REVERSED_IOS_CLIENT_ID

    1. 구글 클라우드 콘솔에 console.cloud.google.com

    2. 프로젝트 찾기

      1. 프로젝트 선택기 구글 클라우드 콘솔 프로젝트 선택기
      2. 이것입니다. sociallogin-tutorial-app. Firebase Project 선택기 프로젝트
    3. 검색 바를 열고 열기 credentials

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

      Google Cloud Console 인증 정보 iOS Client ID
    5. 복사하기 Client ID 그리고 iOS URL scheme이것은 각각의 iOSClientId 및 YOUR_DOT_REVERSED_IOS_CLIENT_ID.

      Google Cloud Console에서
  10. 클라이언트 ID 복사

    1. Firebase 콘솔로 돌아가서 Build -> Authentication Firebase 인증 메뉴로 이동하세요
    2. 버튼을 클릭하세요 Sign-in method 버튼 Firebase 인증 로그인 방법 버튼
    3. 버튼을 클릭하세요 Google 제공자 Firebase 인증 로그인 방법 Google 제공자
    4. 버튼을 클릭하세요 Web SDK configuration 버튼 Firebase 인증 로그인 방법 Web SDK 설정 버튼
    5. 복사하세요 Web client ID. 이 설정은 Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID webClientId in the initialize Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID Firebase Authentication Sign-in Method Web SDK 설정 Web Client ID
  11. Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID

    1. Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID Info.plist file

      Xcode 프로젝트 탐색기에서 Info.plist 파일
    2. Firebase Authentication Sign-in Method Web code 설정 Web Client ID

      Firebase Authentication Sign-in Method Web Code 설정 Web Client ID
    3. Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID Plist Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID </dict> 태그

      Info.plist 파일의 dict 태그를 닫는 곳
    4. Info.plist 파일의 닫는 태그 바로 앞에 다음 코드를 삽입하세요 </dict> 태그

      Info.plist 파일에 URL schemes code을 닫는 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 Info.plist 파일에 실제 역전된 클라이언트 ID를 URL schemes에 삽입

      주의
  12. 변경하여 YOUR_IOS_CLIENT_ID iOS 클라이언트 ID를 복사한 단계 9에서 복사한 ID로 변경합니다

  13. 파일을 저장합니다 Command + S

  14. 수정합니다 AppDelegate.swift

    1. AppDelegate.swift 파일을 Xcode 프로젝트 탐색기에서 열어보세요

      AppDelegate.swift 파일의
    2. Insert import GoogleSignIn 파일의

      AppDelegate.swift 파일의
    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 로그인을 앱에 사용할 준비가 되었습니다. 다음과 같이 사용하세요 authUtils.ts 예제 앱의 authUtils.ts 파일을 사용하여 Google과 인증하세요

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

문제 해결

Troubleshooting

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

  • 인증합니다 idToken 대상이 Firebase 웹 클라이언트 ID와 일치하는지 확인합니다.
  • Firebase 콘솔에서 Google Sign-In이 활성화되어 있는지 확인합니다.
  • Info.plist가 올바른 URL schemes 및 GIDClientID를 가지고 있는지 확인합니다.
  • Verify iOSServerClientId Firebase 웹 클라이언트 ID와 일치하는지 확인합니다.
  • 리뷰하십시오 예시 앱 code 참조용으로

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

iOS에서 Firebase Google Login을 계속 사용하는 방법

Firebase Google Login on iOS를 사용 중이라면 iOS에서 Firebase Google 로그인 인증 및 계정 흐름을 계획하고 연결하려면 Capgo에서 @capgo/capacitor-social-login을 사용합니다. Using @capgo/capacitor-social-login Using @capgo/capacitor-social-login Using @capgo/capacitor-passkey Using @capgo/capacitor-passkey Using @capgo/capacitor-native-biometric Using @capgo/capacitor-native-biometric Using @capgo/capacitor-social-login 두 단계 인증 두 단계 인증 구현에 대한 구체적인 정보