iOS에서 Firebase Google 로그인
설치
이 가이드는 iOS에서 Google Sign-In을 Firebase 인증과 통합하는 방법을 설명합니다. iOS 앱을 Firebase 콘솔에 등록한 경우에만 이 가이드를 따르세요. 일반 Firebase Google 설정.
설치 단계
‘설치 단계’라는 제목의 섹션-
프로젝트 개요를 확인하려면 console.cloud.google.com으로 이동하세요. console.cloud.google.com
-
Firebase Console에서
Add app버튼
-
선택
iOS
-
폼의 첫 번째 부분을 입력하세요
- 두 번째 부분을 입력하세요
Apple bundle ID- Xcode를 앱이 사용하는 곳에서 열어 주세요.
npx cap open ios - Xcode에서
App
- Xcode 프로젝트 탐색기에서 앱이 선택된 상태로
Targets -> App
- 프로젝트 설정에서
Bundle Identifier
- ID를 복사하세요.
Bundle Identifier그것을 Firebase 콘솔에 붙여넣으세요
- Xcode를 앱이 사용하는 곳에서 열어 주세요.
- Firebase 콘솔에서
Register app버튼
- 두 번째 부분을 입력하세요
-
스키핑
Download config file단계
-
스키핑
Add firebase SDK단계
-
스키핑
Add initialization code단계
-
클릭하여
Continue to console버튼
-
iOS 클라이언트 ID와
YOUR_DOT_REVERSED_IOS_CLIENT_ID-
구글 클라우드 콘솔에 console.cloud.google.com
-
프로젝트 찾기
- 프로젝트 선택기
- 이것입니다.
sociallogin-tutorial-app.
- 프로젝트 선택기
-
검색 바를 열고 열기
credentials- 검색 바를 열기
- 를 찾으세요
credentials그리고 검색 바의APIs and Services1 (스크린샷에 표시된 번호 2)
- 검색 바를 열기
-
클릭하세요
iOS client for [YOUR_APP_ID] (auto created by Google Service)1. 나의 경우는sociallogin-tutorial-app.
-
복사하기
Client ID그리고iOS URL scheme이것은 각각의iOSClientId및YOUR_DOT_REVERSED_IOS_CLIENT_ID.
-
-
클라이언트 ID 복사
- Firebase 콘솔로 돌아가서
Build->Authentication
- 버튼을 클릭하세요
Sign-in method버튼
- 버튼을 클릭하세요
Google제공자
- 버튼을 클릭하세요
Web SDK configuration버튼
- 복사하세요
Web client ID. 이 설정은 Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client IDwebClientIdin theinitializeFirebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID
- Firebase 콘솔로 돌아가서
-
Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID
-
Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID
Info.plistfile
-
Firebase Authentication Sign-in Method Web code 설정 Web Client ID
-
Firebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID
PlistFirebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client ID</dict>태그
-
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> -
변경하십시오
YOUR_DOT_REVERSED_IOS_CLIENT_IDInfo.plist 파일에 실제 역전된 클라이언트 ID를 URL schemes에 삽입
-
-
변경하여
YOUR_IOS_CLIENT_IDiOS 클라이언트 ID를 복사한 단계 9에서 복사한 ID로 변경합니다 -
파일을 저장합니다
Command + S -
수정합니다
AppDelegate.swift-
AppDelegate.swift 파일을 Xcode 프로젝트 탐색기에서 열어보세요
-
Insert
import GoogleSignIn파일의
-
구글 소셜 로그인
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:])함수
-
함수를 다음처럼 수정하세요
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 callvar handled: Boolhandled = GIDSignIn.sharedInstance.handle(url)if handled {return true}return ApplicationDelegateProxy.shared.application(app, open: url, options: options)}
-
파일을 다음처럼 저장하세요
Command + S
-
-
Google 로그인을 앱에 사용하는 방법
이 단계에서 Google 로그인을 앱에 사용할 준비가 되었습니다. 다음과 같이 사용하세요 authUtils.ts 예제 앱의 authUtils.ts 파일을 사용하여 Google과 인증하세요
사용자가 Firebase Auth에 처음 로그인할 때 자동으로 생성됩니다
문제 해결
Troubleshooting인증이 지연되거나 실패하는 경우:
- 인증합니다
idToken대상이 Firebase 웹 클라이언트 ID와 일치하는지 확인합니다. - Firebase 콘솔에서 Google Sign-In이 활성화되어 있는지 확인합니다.
- Info.plist가 올바른 URL schemes 및 GIDClientID를 가지고 있는지 확인합니다.
- Verify
iOSServerClientIdFirebase 웹 클라이언트 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 두 단계 인증 두 단계 인증 구현에 대한 구체적인 정보