iOS에서 Firebase Google 로그인
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 지시를 복사하세요.
소개
소개 섹션이 안내서에서는 iOS에서 Google Sign-In을 Firebase Authentication과 통합하는 방법을 설명합니다. Firebase Google 설정을 이미 완료했다고 가정합니다. __CAPGO_KEEP_0__.
설정 단계
설정 단계 섹션-
프로젝트 개요를 확인하려면 console.cloud.google.com
-
클릭 버튼
Add app버튼
-
선택
iOS
-
폼의 첫 번째 부분을 완성하세요
- 완성
Apple bundle ID- Xcode를 사용하여 앱을 열어주세요
npx cap open ios - Double click on
App
- Ensure that you are on
Targets -> App
- Find your
Bundle Identifier
- Copy the
Bundle IdentifierFirebase 콘솔에 붙여넣기
- Xcode를 사용하여 앱을 열어주세요
- 버튼을 클릭하세요.
Register app버튼
- 완성
-
단계를 건너 뛰세요.
Download config file단계
-
단계를 건너 뛰세요.
Add firebase SDKFirebase Add App iOS 다운로드 건너 뛰기 Firebase __CAPGO_KEEP_0__ 버튼
-
단계
Add initialization codeFirebase Add App iOS 다운로드 건너 뛰기 Firebase __CAPGO_KEEP_0__ 버튼
-
클릭하여
Continue to console버튼
-
iOS 클라이언트 ID와
YOUR_DOT_REVERSED_IOS_CLIENT_ID-
Google Cloud Console로 console.cloud.google.com
-
프로젝트를 찾으세요
- 프로젝트 선택기
- Firebase Project Selector Project
sociallogin-tutorial-app.
- 프로젝트 선택기
-
검색 바를 열고 열기
credentials- 검색 바를 열기
- 찾기
credentials및 검색 바에서 클릭APIs and Services스크린샷에 나와있는 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파이어베이스 인증 로그인 방법 웹 __CAPGO_KEEP_0__ 설정 버튼
- 키입니다.
Web client ID키webClientIdFirebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ 설정 Web Client IDinitialize앱의 Info.plist를 수정하세요.
- Firebase 콘솔로 돌아가서 다음 부분의 이 안내서에서 설명한 대로 앱의
-
파일
-
Xcode 프로젝트 탐색기에서 Info.plist 파일을 찾으세요.
Info.plist이 파일을 오른쪽 클릭하고 소스 __CAPGO_KEEP_0__로 열기
-
Right click this file and open it as source code
-
태그를 볼 수 있습니다.
PlistFirebase Authentication Sign-in Method Web __CAPGO_KEEP_0__ Configuration Web Client ID</dict>Modify your app’s 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_ID9번 단계에서 복사한 iOS URL 스키마의 실제 값으로 변경
-
-
Change the
YOUR_IOS_CLIENT_ID__CAPGO_KEEP_0__ -
Save the file with
Command + S -
Modify the
AppDelegate.swift-
Open the AppDelegate
-
Insert
import GoogleSignIn__CAPGO_KEEP_0__ with GoogleSignIn import added
-
__CAPGO_KEEP_0__
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:])function
-
함수를 다음처럼 수정하세요
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 예제 앱의
Firebase Auth에 첫 번째 로그인 시 사용자 자동 생성
문제 해결
“문제 해결” 섹션인증이 지연되거나 실패하는 경우:
- Firebase 웹 클라이언트 ID와 일치하는지 확인하세요.
idTokenFirebase 콘솔에서 Google Sign-In이 활성화되어 있는지 확인하세요. - Info.plist에 올바른 URL schemes과 GIDClientID가 포함되어 있는지 확인하세요.
- Firebase 웹 클라이언트 ID와 일치하는지 확인하세요.
- 예시 앱 __CAPGO_KEEP_0__을 참조하세요.
iOSServerClientId참조용으로 예시 앱을 확인하세요. - 이전으로 example app code 예시 앱 __CAPGO_KEEP_0__