내용으로 건너뛰기

iOS에서 Firebase Google 로그인

이 가이드는 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 앱 추가 버튼
  3. 선택 iOS

    Firebase 앱 추가 iOS 버튼
  4. 폼의 첫 번째 부분을 채우세요

    1. 채우세요 Apple bundle ID
      1. Xcode에서 앱을 열어보세요 npx cap open ios
      2. Xcode 프로젝트 탐색기에서 앱 대상에 두 번 클릭하세요 App Xcode 프로젝트 탐색기에서 앱 대상이 선택되어 있는지 확인하세요
      3. Ensure that you are on 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 버튼을 클릭하세요. Firebase Add App iOS Register Button
  5. 이 단계를 건너뛰세요. Download config file 단계를 건너뛰세요.

    Firebase Add App iOS Skip Download Button
  6. 이 단계를 건너뛰세요. Add firebase SDK 단계를 건너뛰세요.

    Firebase Add App iOS Skip Download Firebase SDK Button
  7. 이 단계를 건너뛰세요. Add initialization code 단계를 건너뛰세요.

    Firebase Add App iOS Skip Add Initialization Code Button
  8. 버튼을 클릭하세요. Continue to console 버튼을 클릭하세요.

    iOS 앱 추가
  9. Firebase 앱에 대한 iOS 클라이언트 ID와 YOUR_DOT_REVERSED_IOS_CLIENT_ID

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

    2. 프로젝트 찾기

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

      1. Google Cloud Console 검색바 __CAPGO_KEEP_0__
      2. __CAPGO_KEEP_0__를 검색하고 credentials __CAPGO_KEEP_1__을 클릭하여 APIs and Services 스크린샷의 2번에 해당하는 구글 클라우드 콘솔 크레디티널 검색
    4. __CAPGO_KEEP_2__을 클릭하여 iOS client for [YOUR_APP_ID] (auto created by Google Service) 1입니다. 나의 경우는 sociallogin-tutorial-app.

      구글 클라우드 콘솔 크레디티널 iOS 클라이언트 ID
    5. __CAPGO_KEEP_3__를 Client ID 그리고 __CAPGO_KEEP_3__를 iOS URL scheme이것은 각각 __CAPGO_KEEP_4__와 __CAPGO_KEEP_5__가 될 것입니다. iOSClientId __CAPGO_KEEP_5__는 __CAPGO_KEEP_4__의 YOUR_DOT_REVERSED_IOS_CLIENT_ID.

      __CAPGO_KEEP_10__ 버튼을 클릭하세요.
  10. __CAPGO_KEEP_11__

    1. __CAPGO_KEEP_12__ button Build -> Authentication __CAPGO_KEEP_13__ button
    2. __CAPGO_KEEP_14__ button Sign-in method __CAPGO_KEEP_15__ button 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 method of the plugin. initialize Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ Configuration 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 파일의 닫는 태그
    4. 닫는 태그 바로 앞에 다음 코드 조각을 삽입하세요 </dict> 닫는 태그 바로 앞에 다음 코드 조각을 삽입하세요

      code URL 스키마를 Info.plist에 삽입하기 전에 닫는 딕셔너리 태그
      <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 스키마로

      Info.plist에 실제로 역전된 클라이언트 ID를 URL 스키마에 삽입합니다.
  12. 변경 YOUR_IOS_CLIENT_ID iOS Client ID를 9번 단계에서 복사한 것과 동일하게

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

  14. 수정하세요. AppDelegate.swift

    1. AppDelegate를 열어보세요.

      Xcode 프로젝트 탐색기에서 AppDelegate.swift 파일을 열어보세요.
    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. __CAPGO_KEEP_0__으로 파일을 저장하세요. Command + S

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

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

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

인증이 걸리거나 실패하는 경우:

  • Firebase 웹 클라이언트 ID와 일치하는지 확인하세요. idToken __CAPGO_KEEP_0__
  • Google Sign-In이 Firebase Console에서 활성화되어 있는지 확인하세요.
  • Info.plist에 올바른 URL schemes과 GIDClientID가 포함되어 있는지 확인하세요.
  • Verify iOSServerClientId 웹 클라이언트 ID와 일치하는지 확인하세요.
  • 참고로 __CAPGO_KEEP_0__ 예제 앱을 확인하세요. example app code 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와 연결하세요. Firebase Google Login on iOS와 연결하세요. Using @capgo/capacitor-social-login for the native capability in Using @capgo/capacitor-social-login, @capgo/capacitor-social-login for the implementation detail in @capgo/capacitor-social-login, @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, and Two-factor authentication for the implementation detail in Two-factor authentication.