iOS에서 Google 로그인
복사할 수 있는 설정 지시어와 이 플러그인의 설치 단계 및 전체 마크다운 가이드를 포함합니다.
이 가이드에서 iOS에서 Google 로그인을 설정하는 방법을 배울 것입니다. Capgo Social Login을 사용하여. 일반적인 설정 가이드를 이미 읽었다고 가정합니다..
iOS에서 Google 로그인을 사용하는 방법
Section titled “iOS에서 Google 로그인을 사용하는 방법”iOS에서 Google 로그인을 설정하는 방법을 배울 것입니다.
-
iOS 클라이언트 ID를 Google 콘솔에서 생성하세요.
-
검색 바를 클릭하세요.
-
검색하고
credentials클릭하세요.APIs and Services1번 (스크린샷에서 2번)
-
Google Console의
create credentials
-
인증 정보 생성 메뉴에서
OAuth client ID
-
Live Update
Application typeiOS 옵션을 선택한 애플리케이션 유형 선택iOS
-
Xcode를 열으세요
-
Xcode 프로젝트 탐색기에서
-
App Target을 더블 클릭하세요
App
-
이것을 확인하세요.
Targets -> App
-
찾아보세요.
Bundle Identifier
-
Google 콘솔로 돌아가서 Bundle ID 필드에 자신의
Bundle Identifier를 입력하세요.Bundle ID
-
-
또는
App Store IDGoogle 콘솔 iOS 클라이언트 생성 양식의 Bundle ID 필드에Team ID입력하세요. -
선택적으로
create
-
클릭
OK
-
새로 생성된 iOS 클라이언트 열기
-
다음 데이터 복사
-
-
앱의 Info.plist 파일을 수정하세요
-
Xcode를 열고 프로젝트 탐색기에서
Info.plist파일
-
파일을 오른쪽 클릭하고 소스 code로 열기
-
파일의 하단 부분에서
Plist태그</dict>Info.plist 파일의 dict 태그
-
구글 소셜 로그인 플러그인 iOS
</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이전 단계에서 복사한 값으로
-
파일을 저장하세요.
Command + S
-
-
수정하세요.
AppDelegate.swift-
AppDelegate를 열어보세요.
-
삽입하세요.
import GoogleSignInAppDelegate.swift 파일의 맨 위에 GoogleSignIn import를 추가하세요.
-
함수
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:])AppDelegate의 원래 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)}
-
파일을 저장하세요.
Command + S
-
-
Setup Google login in your JavaScript/TypeScript code
-
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'}})}) -
구글 로그인 기능을 구현하세요. 버튼을 만들고 클릭 시 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 로그인 플러그인은 @capacitor/privacy-screen개인 정보 보호 화면이 로그인 웹뷰를 중단할 수 있습니다.
해결 방법: 호출하기 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 로그인 계속하기Google 로그인 iOS를 사용 중이라면 Google 로그인 iOS 인증 및 계정 흐름을 계획하고 연결하려면 Using @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 두 단계 인증 두 단계 인증 구현 세부 사항에 대한 정보입니다.