메뉴로 이동

iOS에서 Google 로그인

GitHub

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 iOS에서 Google 로그인을 사용하는 방법.

이 섹션에서는 iOS에서 Google 로그인을 설정하는 방법을 배울 것입니다.

이 안내서에서는 iOS에서 Google 로그인을 설정하는 방법을 배울 것입니다.

이 안내서에서는 iOS에서 Google 로그인을 설정하는 방법을 배울 것입니다.

  1. iOS 클라이언트 ID를 Google 콘솔에서 생성하세요.

    1. 검색 바 클릭

      Google 콘솔 검색 바
    2. 를 검색하세요. credentials API 및 서비스가 강조된 자격 증명 옵션을 보여주는 검색 결과 APIs and Services Google 콘솔에서

      Create credentials 버튼을 클릭하세요.
    3. APIs & Services에서 create credentials

      OAuth 클라이언트 ID 옵션을 자격 증명 생성 메뉴에서 선택하세요.
    4. APIs & Services에서 자격 증명 옵션을 선택하세요. OAuth client ID

      APIs & Services에서 자격 증명 옵션을 선택하세요.
    5. APIs & Services에서 자격 증명 옵션을 선택하세요. Application type iOS 옵션을 강조한 애플리케이션 유형 선택 iOS

      Bundle ID를 찾으세요
    6. Xcode를 열어보세요

      1. Xcode 프로젝트 탐색기에서

      2. App 대상 App

        Xcode 프로젝트 설정에서 Bundle Identifier 필드를 찾으세요
      3. Google Console로 돌아가서 Bundle ID를 붙여넣으세요 Targets -> App

        __CAPGO_KEEP_0__
      4. Xcode 프로젝트 설정에서 Targets 섹션에 App을 선택하세요 Bundle Identifier

        Bundle Identifier 필드를 찾으세요
      5. Xcode 프로젝트 탐색기에서 App 대상에 두 번 클릭하세요 Bundle Identifier Xcode 프로젝트 설정에서 Targets 섹션에 App을 선택하세요 Bundle ID

        __CAPGO_KEEP_0__ ID 필드에 Google Console iOS 클라이언트 생성 양식에
    7. Optionally, add your App Store ID or Team ID App Store에 앱을 출시한 경우에만

    8. After filling all the details, click create

      iOS 클라이언트 생성 양식 하단의
    9. Click OK

      확인 대화 상자에
    10. Open the newly created iOS client

      새로 생성된 iOS 클라이언트가
    11. Copy the following data

      Client ID details showing Client ID and reversed client ID to copy
  2. 앱의 Info.plist를 수정하세요.

    1. Xcode에서 열고 프로젝트 탐색기에서 Info.plist 파일

      Info.plist 파일을 Xcode 프로젝트 탐색기에서 찾으세요.
    2. 오른쪽 클릭하여 이 파일을 소스 code로 열어보세요.

      Open As Source Code 옵션을 보여주는 오른쪽 클릭 메뉴.
    3. 파일의 하단에서 Plist 파일의 하단에서 </dict> 태그

      Info.plist 파일의 Closing dict 태그
    4. 닫는 태그 바로 앞에 다음 코드를 삽입하세요. </dict> URL schemes __CAPGO_KEEP_0__를 Info.plist에 삽입한 파일

      Info.plist with URL schemes code inserted before closing dict tag
      <key>CFBundleURLTypes</key>
      <array>
      <dict>
      <key>CFBundleURLSchemes</key>
      <array>
      <string>YOUR_DOT_REVERSED_IOS_CLIENT_ID</string>
      </array>
      </dict>
      </array>
    5. 이 값으로 바꿔보세요. YOUR_DOT_REVERSED_IOS_CLIENT_ID to the value copied in the previous step

      __CAPGO_KEEP_0__ URL schemes에 실제 역순 클라이언트 ID가 삽입된 Info.plist
    6. __CAPGO_KEEP_0__ 파일을 Command + S

  3. __CAPGO_KEEP_1__을 수정하여 AppDelegate.swift

    1. AppDelegate

      Xcode 프로젝트 탐색기에서 AppDelegate.swift 파일을 열어
    2. __CAPGO_KEEP_2__을 삽입하여 import GoogleSignIn __CAPGO_KEEP_3__의 위쪽에

      AppDelegate.swift에 GoogleSignIn import를 추가했습니다.
    3. Find the func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) function

      AppDelegate의 원래 openURL 함수
    4. Modify the function to look like this

      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 call
      var handled: Bool
      handled = GIDSignIn.sharedInstance.handle(url)
      if handled {
      return true
      }
      return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
      }
      GoogleSignIn을 처리하는 수정된 애플리케이션 openURL 함수
    5. Save the file with Command + S

  4. Google 로그인 설정을 JavaScript/TypeScript code에서

    1. Import SocialLogin and Capacitor

      import { SocialLogin } from '@capgo/capacitor-social-login';
      import { Capacitor } from '@capacitor/core';
    2. __CAPGO_KEEP_0__을 호출하세요 (한 번만 호출하세요)

      기본 설정 (온라인 모드 - 대부분의 앱에 권장):

      // onMounted is Vue specific
      onMounted(() => {
      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 support
      iOSClientId: 'YOUR_IOS_CLIENT_ID', // Required: from step 1
      iOSServerClientId: 'YOUR_WEB_CLIENT_ID', // Optional: same as webClientId, needed for some advanced features
      mode: 'online' // 'online' or 'offline'
      }
      })
      })
    3. 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 data
      console.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 mode
      console.log('Server auth code:', res.result.serverAuthCode)
  5. protectedTokens

    1. 애플리케이션을 빌드하고 실행하세요 cap sync

    2. 모든 것을 올바르게 수행했다면, Google 로그인 흐름이 올바르게 작동하는 것을 볼 수 있어야 합니다

      iOS에서 Google 로그인 흐름의 데모, 로그인 프로세스 및 인증 성공

알려진 문제

알려진 문제

개인 정보 보호 화면 플러그인 불일치

개인 정보 보호 화면 플러그인 불일치

Google 로그인 플러그인은 @capacitor/privacy-screen. Google 로그인 웹뷰가 개인화 화면에 의해 중단될 수 있습니다.

Workaround: Call await PrivacyScreen.disable(); Google 로그인 함수를 호출하기 전에

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 Login on iOS를 사용하여 인증 및 계정 흐름을 계획하고 계정에 연결하세요. Using @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-social-login Using @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-social-login for the native capability in Using @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-social-login, Using @capgo/capacitor-social-login for the native capability in Using @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에서 확인할 수 있습니다. 두 단계 인증 구현 세부 사항은 두 단계 인증에서 확인할 수 있습니다.