iOS에서 Google 로그인
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 명령어를 복사하세요.
이 가이드에서 Google 로그인과 Capgo iOS용 Social Login을 설정하는 방법을 배웁니다. 이미 이 가이드의 내용을 읽으셨다고 가정합니다. 설정 가이드.
iOS에서 Google 로그인을 사용하는 방법
iOS에서 Google 로그인을 사용하는 방법iOS에서 Google 로그인을 설정하는 방법에 대해 배울 것입니다.
-
iOS 클라이언트 ID를 Google 콘솔에 생성하세요.
-
검색 바를 클릭하세요.
-
검색하세요.
credentials그리고APIs and Services스크린샷의 2번에 표시된 옵션을 클릭하세요.
-
자격 증명 옵션을 클릭하세요.
create credentials
-
Select
OAuth client ID
-
Select the
Application typeiOSiOS
-
Bundle ID를 찾으세요.
-
Xcode를 열어보세요.
-
App target을
App
-
Capgo가 App target을 선택한 상태에서 Targets 섹션에 있습니다.
Targets -> App
-
Find your
Bundle Identifier
-
Google Console로 돌아가서 앱의
Bundle IdentifierBundle ID 필드에 붙여넣으세요.Bundle ID
-
-
App Store에 앱을 출시한 경우, 앱의
App Store ID또는Team IDApp Store에 앱을 출시한 경우, 앱의 -
클라이언트 ID에 붙여넣으세요.
create
-
iOS 클라이언트 생성 폼 하단의
OK
-
iOS 클라이언트를 새로 생성한 것을 열어주세요.
-
다음 데이터를 복사하세요.
-
-
__CAPGO_KEEP_0__
-
Xcode에서 프로젝트 탐색기에서
Info.plist파일
-
이 파일을 오른쪽 클릭하고 소스 코드로 열기 code
-
파일의 하단 부분에서
Plist파일의 하단 부분에서</dict>태그
-
닫는 태그 바로 앞에 다음 코드 조각을 삽입하세요.
</dict>__CAPGO_KEEP_0__
<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLSchemes</key><array><string>YOUR_DOT_REVERSED_IOS_CLIENT_ID</string></array></dict></array> -
이전 단계에서 복사한 값을
YOUR_DOT_REVERSED_IOS_CLIENT_ID으로 변경
-
파일을 저장하세요.
Command + S
-
-
이 값을 수정하세요.
AppDelegate.swift-
Xcode 프로젝트 탐색기에서 AppDelegate.swift 파일을 열어 주세요.
-
위에
import GoogleSignInAppDelegate.swift 파일에 GoogleSignIn import를 추가한 파일을 열어 주세요.
-
함수
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:])AppDelegate.swift 파일의 원래 openURL 함수를 찾으세요.
-
클립보드에 복사하세요.
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)}
-
AppDelegate.swift 파일에 GoogleSignIn import를 추가한 파일을 열어 주세요.
Command + S
-
-
code에 Google 로그인을 설정하세요.
-
Import
SocialLogin및Capacitorimport { SocialLogin } from '@capgo/capacitor-social-login';import { Capacitor } from '@capacitor/core'; -
initialize 메소드를 호출하세요 (이 메소드는 한 번만 호출해야 합니다).
기본 설정 (온라인 모드 - 대부분의 앱에 권장):
// onMounted is Vue specificonMounted(() => {SocialLogin.initialize({google: {iOSClientId: '673324426943-redacted.apps.googleusercontent.com',mode: 'online' // Default mode}})})추가 클라이언트 ID를 사용하는 고급 설정:
onMounted(() => {SocialLogin.initialize({google: {webClientId: 'YOUR_WEB_CLIENT_ID', // Optional: for web platform supportiOSClientId: 'YOUR_IOS_CLIENT_ID', // Required: from step 1iOSServerClientId: 'YOUR_WEB_CLIENT_ID', // Optional: same as webClientId, needed for some advanced featuresmode: 'online' // 'online' or 'offline'}})}) -
로그인 함수를 구현하세요. 버튼을 만들고 클릭 시 다음 code을 실행하세요.
온라인 모드:
const res = await SocialLogin.login({provider: 'google',options: {}})// handle the response - contains user dataconsole.log(JSON.stringify(res))오프라인 모드에 사용할 경우:
const res = await SocialLogin.login({provider: 'google',options: {forceRefreshToken: true // Recommended for offline mode}})// res contains serverAuthCode, not user data// Send serverAuthCode to your backend to get user information// Do not call SocialLogin.refresh() in offline modeconsole.log('Server auth code:', res.result.serverAuthCode)
-
-
애플리케이션 테스트
-
앱을 빌드하고 실행하세요
cap sync -
모든 것을 올바르게 완료했다면, Google 로그인 흐름이 올바르게 작동하는 것을 볼 수 있어야 합니다.
-
알려진 문제
알려진 문제개인 정보 보호 화면 플러그인 불일치
개인 정보 보호 화면 플러그인 불일치 섹션Google 로그인 플러그인은 @capacitor/privacy-screen개인 정보 보호 화면이 Google 로그인 웹뷰를 중단할 수 있습니다.
해결 방법: Call await PrivacyScreen.disable(); 로그인 함수를 호출하기 전에
import { PrivacyScreen } from '@capacitor/privacy-screen';import { SocialLogin } from '@capgo/capacitor-social-login';
await PrivacyScreen.disable();await SocialLogin.login({ provider: 'google', options: {}});iOS에서 Google 로그인으로 계속하기
iOS에서 Google 로그인으로 계속하기 섹션iOS에서 Google 로그인을 사용하는 경우 iOS에서 Google 로그인 인증 및 계정 흐름을 계획하고 연결하려면 @capgo/capacitor-social-login을 사용하여 @capgo/capacitor-social-login의 네이티브 기능을 사용하여 @capgo/capacitor-social-login @capgo/capacitor-social-login의 구현 세부 정보를 위해 @capgo/capacitor-passkey @capgo/capacitor-passkey의 구현 세부 정보를 위해 @capgo/capacitor-native-biometric @capgo/capacitor-native-biometric의 구현 세부 정보를 위해, iOS에서 두 단계 인증 두 단계 인증의 구현 세부 정보를 위해.