Facebook 로그인 마이그레이션 @capgo/social-login
이 설정 프롬프트를 복사하여 설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함합니다.
이 가이드는 Facebook 인증을 위한 최신 플러그인으로의 전환을 위한 포괄적인 지침을 제공합니다. @capacitor-community/facebook-login Live Update @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.
설치
설치-
기존 패키지를 삭제하세요:
터미널 창 npm uninstall @capacitor-community/facebook-login -
새로운 패키지를 설치하세요:
터미널 창 npm install @capgo/capacitor-social-loginnpx cap sync
Code 변경 사항
Section titled “Code Changes”변경 사항 가져오기
변경 사항 가져오기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:
- 응답에는 인증 제공자 식별하는
providerfield가 포함됩니다 - 추가 사용자 정보가 포함된
profileobject - 모든 사회 로그인 제공자에서 일관된 구조
로그인 상태 확인
제목이 ‘로그인 상태 확인’인 섹션const result = await FacebookLogin.getCurrentAccessToken();const isLoggedIn = result && result.accessToken;
const status = await SocialLogin.isLoggedIn({ provider: 'facebook'});const isLoggedIn = status.isLoggedIn;로그아웃
로그아웃 섹션await FacebookLogin.logout();
await SocialLogin.logout({ provider: 'facebook'});플랫폼별 변경 사항
플랫폼별 변경 사항 섹션안드로이드 설정
안드로이드 설정 섹션초기화 메서드를 통해 설정이 처리됩니다:
// 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 }});중요클라이언트 토큰이 이제 안드로이드 인증에 필요합니다.
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])- 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>클립보드에 복사
변경 사항제목: 변경 사항
- iOS 설정을 다른 플랫폼으로 이전할 때 발생하는 변경 사항의 요약: explicit 초기화가 필요합니다
initialize()- 사용하기 전에 반드시 호출해야 함 - 응답 객체 구조가 크게 변경되었습니다. - 새로운 결과 형식과 향상된 프로필 데이터가 포함된 중첩된 결과 형식
- 안드로이드용 클라이언트 토큰이 필요합니다. - 추가적인 구성이 필요합니다.
- 메서드 이름과 매개 변수 구조가 다릅니다. - 제공자 기반 접근 방식
- 오류 처리 및 오류 유형이 변경되었습니다. - 더 자세한 오류 정보
주요 이점
주요 이점새로운 플러그인은 다음과 같은 이점을 제공합니다.
- 통합 API 다양한 소셜 제공자 (Google, Apple, Facebook)에서
- 향상된 TypeScript 지원 타입 정의가 더 좋아졌습니다
- 개선된 프로필 데이터 사용자 정보가 더 많습니다
- 활발한 유지 관리 및 커뮤니티 지원
- 모든 제공자에서 일관된 오류 처리 모든 제공자에서 일관된 오류 처리
- 토큰 관리가 더 좋아졌습니다 유효 기간이 제대로 처리되었습니다
세부한 설정 지침에 대한 자세한 설명은 공식 문서.
Facebook 로그인 마이그레이션에서 @capgo/social-login으로 계속 진행하세요
제목 "Facebook 로그인 마이그레이션에서 @capgo/social-login으로 계속 진행하세요"Facebook 로그인 마이그레이션을 사용 중이시면 Facebook 로그인 마이그레이션을 @capgo/social-login으로 사용하여 인증 및 계정 흐름을 계획하고 Facebook 로그인 마이그레이션을 @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-social-login으로 사용하여 Facebook 로그인 마이그레이션을 @capgo/capacitor-social-login으로 사용하여 Facebook 로그인 마이그레이션을 @capgo/capacitor-social-login으로 사용하여 Facebook 로그인 마이그레이션을 @capgo/capacitor-passkey으로 사용하여 Facebook 로그인 마이그레이션을 @capgo/capacitor-passkey으로 사용하여 @capgo/capacitor-social-login @capgo/capacitor-passkey @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, and 두 단계 인증 두 단계 인증 구현 세부 사항에 대해