iOS에서 Google 로그인
이 플러그인에 대한 설치 단계와 전체 마크다운 가이드를 포함하여 설정 프롬프트를 복사하세요.
소개
소개In this guide, you will learn how to setup Google Login with Capgo Social Login for iOS. I assume that you have already read the 이 가이드에서, __CAPGO_KEEP_0__ Social Login for iOS와 Google 로그인을 설정하는 방법을 배울 것입니다. 이 가이드를 읽기 전에 이미 일반 설정 가이드를 읽었다고 가정합니다..
iOS에서 Google 로그인 사용하기
iOS에서 Google 로그인 사용하기이 부분에서 iOS에서 Google 로그인을 설정하는 방법을 배울 것입니다.
-
iOS 클라이언트 ID를 Google 콘솔에 생성하세요.
-
검색 바 클릭
-
검색하세요
credentialsAPIs 및 Services가 강조된 자격 증명 옵션을 보여주는 검색 결과APIs and Services자격 증명 옵션에 클릭하세요.
-
자격 증명 생성 메뉴에서 OAuth 클라이언트 ID 옵션을 선택하세요.
create credentials
-
__CAPGO_KEEP_0__
OAuth client ID
-
선택하세요.
Application type__CAPGO_KEEP_0__iOS
-
버블 ID를 찾으세요.
-
Xcode를 열어보세요.
-
Xcode 프로젝트 탐색기에서 앱 대상에 두 번 클릭하세요.
App
-
Xcode에서 Targets 섹션에 앱이 선택되어 있는지 확인하세요.
Targets -> App
-
Google Console로 돌아가서 Bundle ID를 붙여넣으세요.
Bundle Identifier
-
__CAPGO_KEEP_0__
Bundle Identifier__CAPGO_KEEP_0__Bundle ID
-
-
__CAPGO_KEEP_2__를 선택적으로 추가하여
App Store ID__CAPGO_KEEP_3__에 앱을 App Store에 게시한 경우 클라이언트 ID에 입력하세요.Team ID모든 세부 정보를 입력한 후 -
iOS 클라이언트 생성 양식 하단의 Create 버튼을 클릭하세요.
create
-
OK 버튼을 클릭하세요.
OK
-
인증서 목록에 새로 생성된 iOS 클라이언트를 확인하세요.
-
__CAPGO_KEEP_4__ 데이터를 복사하세요.
-
-
__CAPGO_KEEP_0__
-
__CAPGO_KEEP_0__
Info.plist__CAPGO_KEEP_0__
-
이 파일을 오른쪽 클릭하고 code으로 열기
-
Info.plist 파일의
Plist태그</dict>Info.plist 파일의
-
Info.plist 파일의
</dict>태그
<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__CAPGO_KEEP_0__
-
파일을
Command + S
-
-
수정
AppDelegate.swift-
Xcode 프로젝트 탐색기에서
-
삽입
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
-
-
JavaScript/TypeScript code에서 Google 로그인 설정
-
import
SocialLogin그리고Capacitorimport { SocialLogin } from '@capgo/capacitor-social-login';import { Capacitor } from '@capacitor/core'; -
초기화 메서드를 호출하십시오 (이 메서드는 한 번만 호출되어야 함)
기본 설정 (온라인 모드 - 대부분의 앱에 권장):
// 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'}})}) -
Implement the login function. Create a button and run the following code on click
클립보드 복사
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)
-
-
__CAPGO_KEEP_0__
-
__CAPGO_KEEP_1__
cap sync -
__CAPGO_KEEP_2__
-
__CAPGO_KEEP_7__
__CAPGO_KEEP_8____CAPGO_KEEP_9__
__CAPGO_KEEP_10____CAPGO_KEEP_11__ @capacitor/개인정보 보호 화면Google 로그인 웹뷰와 함께 사용할 때, 개인정보 보호 화면이 로그인 화면을 중단합니다.
해결 방법: 호출하기 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: {}});