Facebook Login 이주 @capgo/social-login으로
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
개요
개요이 가이드는 에서 로의 마이그레이션에 대한 포괄적인 지침을 제공합니다. 새로운 플러그인은 Facebook 인증을 현대화하고 여러 소셜 제공자, 향상된 TypeScript 지원 및 향상된 기능을 지원하는 통합 __CAPGO_KEEP_0__를 제공합니다. @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 인증을 현대화하고 여러 소셜 제공자, 향상된 TypeScript 지원 및 향상된 기능을 지원하는 통합 __CAPGO_KEEP_0__를 제공합니다.
설치-
__CAPGO_KEEP_0__ Changes
터미널 창 npm uninstall @capacitor-community/facebook-login -
__CAPGO_KEEP_0__ 패키지 설치:
터미널 창 npm install @capgo/capacitor-social-loginnpx cap sync
Code 변경 사항
Code 변경 사항변경 사항 가져오기
__CAPGO_KEEP_0__ 변경 사항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 }});로그인
로그인 섹션로그인 메서드는 이제 제공자 매개 변수를 받을 수 있습니다:
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' }});응답 형식 변경
응답 형식 섹션응답 구조는 더 광범위한 프로필 객체로 현대화되었습니다:
// 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; }; };}Key Differences:
- __CAPGO_KEEP_0__
provider__CAPGO_KEEP_0__ 인증 제공자 필드 - __CAPGO_KEEP_0__에 대한 더 자세한 정보
profile모든 소셜 로그인 제공자에서 일관된 구조 - 로그인 상태 확인
로그인 상태 확인 섹션
__CAPGO_KEEP_0__ 복사const result = await FacebookLogin.getCurrentAccessToken();const isLoggedIn = result && result.accessToken;
const status = await SocialLogin.isLoggedIn({ provider: 'facebook'});const isLoggedIn = status.isLoggedIn;로그아웃 섹션
__CAPGO_KEEP_0__ 복사await FacebookLogin.logout();
await SocialLogin.logout({ provider: 'facebook'});플랫폼별 변경 사항
플랫폼별 변경 사항 섹션Android 설정
Android 설정 섹션initialize 메서드를 통해 구성이 처리됩니다.
// 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.swiftremains the same:
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])- The
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()응답 객체 구조가 크게 변경되었습니다 - - 새로 고친 결과 형식과 향상된 프로필 데이터와 함께嵌套된 형식이 있습니다. __CAPGO_KEEP_0__
- __CAPGO_KEEP_0__ Android 클라이언트 토큰이 필요합니다.
- - 추가 설정이 필요합니다. - 다양한 메서드 이름과 매개 변수 구조가 있습니다.
- - 제공자 기반 접근법 - 오류 처리 및 오류 유형이 변경되었습니다.
- 더 자세한 오류 정보
Key AdvantagesKey Advantages
- Unified API __CAPGO_KEEP_0__
- 다양한 소셜 제공자 (Google, Apple, Facebook)across에 통합되었습니다. Improved TypeScript 지원이 향상되었습니다. __CAPGO_KEEP_0__
- 개선된 프로필 데이터 사용자 정보가 더 많습니다
- 활발한 유지 보수 커뮤니티 지원
- 일관된 오류 처리 모든 제공자에서
- 토큰 관리가 더 좋습니다 만료 처리가 올바르게 수행됩니다
세부한 설정 지침에 대한 자세한 내용은 공식 문서.
Facebook 로그인 마이그레이션에서 계속 진행하세요 @capgo/social-login
Facebook 로그인 이주에서 @capgo/social-login로 계속 진행하세요이용 중인 경우 Facebook 로그인 이주를 @capgo/social-login으로 인증 및 계정 흐름을 계획하고 연결하려면 @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의 구현 세부 정보를 위해 두 단계 인증 for the implementation detail in 두 단계 인증.