Facebook 로그인 마이그레이션을 @capgo/social-login으로 진행하세요
이 플러그인의 설치 단계와 전체 마크다운 가이드가 포함된 설정 프롬프트를 복사하세요.
This guide provides comprehensive instructions for migrating from @capacitor-community/facebook-login 으로 @capgo/capacitor-social-login. The new plugin modernizes Facebook authentication with a unified API that supports multiple social providers, improved TypeScript support, and enhanced capabilities.
에
새로운 플러그인은 Facebook 인증을 현대화하는 통합 __CAPGO_KEEP_0__를 제공하며 여러 소셜 제공자, 향상된 TypeScript 지원 및 향상된 기능을 지원합니다.-
설치
Section titled “설치” npm uninstall @capacitor-community/facebook-login -
터미널 창
복사 npm install @capgo/capacitor-social-loginnpx cap sync
Code 변경 사항
Code 변경 사항 섹션변경 사항 가져오기
변경 사항 가져오기 섹션import { FacebookLogin } from '@capacitor-community/facebook-login';import { SocialLogin } from '@capgo/capacitor-social-login';초기화
섹션 제목 “초기화”키 변경: 새로운 패키지는 code에서 명시적인 설정이 필요합니다.
// Old package required no explicit initialization in code// Configuration was done only in native platforms
// New package requires explicit initializationawait SocialLogin.initialize({ facebook: { appId: 'YOUR_FACEBOOK_APP_ID', // Required for web and Android clientToken: 'YOUR_CLIENT_TOKEN' // Required for Android }});로그인
섹션 제목 “로그인”__CAPGO_KEEP_0__ 방법은 제공자 매개 변수를 받을 수 있습니다.
const FACEBOOK_PERMISSIONS = ['email', 'public_profile'];const result = await FacebookLogin.login({ permissions: FACEBOOK_PERMISSIONS });
const result = await SocialLogin.login({ provider: 'facebook', options: { permissions: ['email', 'public_profile'], limitedLogin: false, nonce: 'optional_nonce' }});__CAPGO_KEEP_0__ 유형 변경
__CAPGO_KEEP_0__ 유형 변경 섹션 제목__CAPGO_KEEP_0__ 구조는 더 광범위한 프로필 객체로 현대화되었습니다.
// Old response typeinterface FacebookLoginResponse { accessToken: { applicationId: string; userId: string; token: string; expires: string; }; recentlyGrantedPermissions: string[]; recentlyDeniedPermissions: string[];}
// New response typeinterface FacebookLoginResponse { provider: 'facebook'; result: { accessToken: { token: string; applicationId?: string; expires?: string; userId?: string; permissions?: string[]; declinedPermissions?: string[]; } | null; idToken: string | null; profile: { userID: string; email: string | null; friendIDs: string[]; birthday: string | null; ageRange: { min?: number; max?: number } | null; gender: string | null; location: { id: string; name: string } | null; hometown: { id: string; name: string } | null; profileURL: string | null; name: string | null; imageURL: string | null; }; };}__CAPGO_KEEP_0__의 차이점:
- __CAPGO_KEEP_0__에는 인증 제공자 식별을 위한 field가 포함됩니다.
provider__CAPGO_KEEP_0__는 추가 사용자 정보를 포함하는 더 자세한 객체입니다. - __CAPGO_KEEP_0__는 모든 사회 로그인 제공자에서 일관된 구조를 제공합니다.
profile__CAPGO_KEEP_1__ - __CAPGO_KEEP_0__
로그인 상태 확인
Checking Login Statusconst result = await FacebookLogin.getCurrentAccessToken();const isLoggedIn = result && result.accessToken;
const status = await SocialLogin.isLoggedIn({ provider: 'facebook'});const isLoggedIn = status.isLoggedIn;Section titled “Checking Login Status”
로그아웃await FacebookLogin.logout();
await SocialLogin.logout({ provider: 'facebook'});Android 설정
// AndroidManifest.xml changes remain the same// strings.xml become irrelevant// Additionally initialize in your code:await SocialLogin.initialize({ facebook: { appId: 'your-app-id', clientToken: 'your-client-token' // New requirement }});중요: Android 인증을 위해 클라이언트 토큰이 필요합니다.
iOS 설정
iOS 설정- iOS 설정은
AppDelegate.swift변하지 않습니다.
import FBSDKCoreKit
// In application:didFinishLaunchingWithOptions:FBSDKCoreKit.ApplicationDelegate.shared.application( application, didFinishLaunchingWithOptions: launchOptions)
// In application:openURL:options:ApplicationDelegate.shared.application( app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplication.OpenURLOptionsKey.annotation])- 설정은
Info.plist변하지 않습니다.
<key>CFBundleURLTypes</key><array> <dict> <key>CFBundleURLSchemes</key> <array> <string>fb[APP_ID]</string> </array> </dict></array><key>FacebookAppID</key><string>[APP_ID]</string><key>FacebookClientToken</key><string>[CLIENT_TOKEN]</string><key>FacebookDisplayName</key><string>[APP_NAME]</string><key>LSApplicationQueriesSchemes</key><array> <string>fbapi</string> <string>fbauth</string> <string>fb-messenger-share-api</string> <string>fbauth2</string> <string>fbshareextension</string></array>중단 변경 사항
중단 변경 사항이동 시 발생하는 변경 사항의 요약:
- explicit 초기화가 필요합니다. - 사용하기 전에 호출해야 함
initialize()응답 객체 구조가 크게 변경되었습니다. - - 향상된 프로필 데이터를 포함하는 새로운 중첩된 결과 형식 Android에서 클라이언트 토큰이 필요합니다.
- - 추가 구성이 필요합니다. 메서드 이름과 매개 변수 구조가 다릅니다.
- - 제공자 기반 접근법 오류 처리 및 오류 유형이 변경되었습니다.
- - 더 자세한 오류 정보 __CAPGO_KEEP_0__
Key Advantages
Key Advantages 섹션새로운 플러그인은 다음과 같은 기능을 제공합니다:
- 일관적인 API 다양한 소셜 제공자 (Google, Apple, Facebook)across
- TypeScript 지원이 향상되었습니다. 타입 정의가 더 좋아졌습니다.
- 프로필 데이터가 향상되었습니다. 사용자 정보가 더 많습니다.
- 활발한 유지 보수 커뮤니티 지원
- 일관적인 오류 처리 모든 제공자에서
- 보다 나은 토큰 관리 적절한 만료 처리와 함께
세부한 설정 지침에 대한 자세한 내용은 공식 문서를 참조하십시오. 공식 문서.
Facebook 로그인 마이그레이션에서 @capgo/social-login로 계속 진행하세요.
Facebook 로그인 마이그레이션에서 @capgo/social-login로 계속 진행하세요.Facebook 로그인 마이그레이션을 @__CAPGO_KEEP_0__/social-login으로 사용 중이시면 Facebook 로그인 마이그레이션을 @capgo/social-login으로 사용 중이시면 인증 및 계정 흐름을 계획하고 연결하려면 @__CAPGO_KEEP_0__/social-login을 사용하세요. Facebook 로그인 마이그레이션을 @capgo/capacitor-social-login으로 사용 중이시면 Facebook 로그인 마이그레이션을 @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 구현 세부 사항을 참조하십시오. 그리고 두 단계 인증 두 단계 인증 구현 세부 사항을 참조하십시오.