메인 콘텐츠로 건너뛰기

Facebook 로그인 마이그레이션을 @capgo/social-login으로 진행하세요

GitHub

__CAPGO_KEEP_0__에서 이주하는 데 필요한 모든 지침을 제공하는 이 안내서입니다. @capacitor-community/facebook-login Capacitor @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.

터미널 창

복사
  1. 새 패키지를 설치하세요:

    터미널 창
    npm uninstall @capacitor-community/facebook-login
  2. __CAPGO_KEEP_0__

    __CAPGO_KEEP_0__
    npm install @capgo/capacitor-social-login
    npx cap sync
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 initialization
await 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__

// Old response type
interface FacebookLoginResponse {
accessToken: {
applicationId: string;
userId: string;
token: string;
expires: string;
};
recentlyGrantedPermissions: string[];
recentlyDeniedPermissions: string[];
}
// New response type
interface 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;
};
};
}

차이점:

  • 응답에는 인증 공급자 provider 더 자세한
  • 사용자 정보가 포함된 객체 profile 가 포함됩니다.
  • 모든 사회 로그인 제공자에서 일관된 구조

로그인 상태 확인

로그인 상태 확인
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'
});

플랫폼별 변경 사항

플랫폼별 변경 사항

안드로이드 설정

안드로이드 설정

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
}
});

중요: 안드로이드 인증을 위해 클라이언트 토큰이 필요합니다.

iOS 설정

iOS 설정
  1. 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]
)
  1. 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>

중요한 변경 사항

변경 사항

업그레이드 시 변경 사항 요약

  1. explicit 초기화가 필요합니다 - 사용하기 전에 호출해야 함 initialize() 응답 객체 구조가 크게 변경되었습니다
  2. - 프로필 데이터가 향상된 새로된 결과 형식 Android에서 클라이언트 토큰이 필요합니다
  3. - 추가 구성이 필요합니다 메서드 이름과 매개 변수 구조가 다릅니다
  4. - 제공자 기반 접근 방식 오류 처리 및 오류 유형이 변경되었습니다
  5. __CAPGO_KEEP_0__ - 더 자세한 오류 정보

새로운 플러그인은 다음과 같은 기능을 제공합니다:

  • 통합 API 다중 소셜 제공자 (Google, Apple, Facebook)across
  • 향상된 TypeScript 지원 더 나은 타입 정의
  • 향상된 프로필 데이터 더 많은 사용자 정보
  • 활발한 유지 보수 커뮤니티 지원
  • 일관된 오류 처리 모든 제공자에서
  • 적절한 만료 처리와 함께 더 나은 토큰 관리 모든 제공자에서

세부한 설정 지침에 대한 자세한 내용은 공식 문서를 참조하십시오. Facebook 로그인 마이그레이션에서 계속.

Keep going from Facebook Login Migration to @capgo/social-login

Section titled “Keep going from Facebook Login Migration to @capgo/social-login”

Facebook 로그인 마이그레이션을 사용하여 인증 및 계정 흐름을 계획하고 있습니다. 이에 대해 연결하세요. Facebook Login Migration to @capgo/social-login Facebook 로그인 마이그레이션을 사용하여 인증 및 계정 흐름을 계획하고 있습니다. 이에 대해 연결하세요. Using @capgo/capacitor-social-login Capgo의 Native 기능을 사용하는 @capgo/capacitor-social-login을 위해 @capgo/capacitor-social-login Capgo의 Native 기능을 사용하는 @capgo/capacitor-social-login의 구현 세부 사항을 위해 @capgo/capacitor-passkey Capgo의 Native 기능을 사용하는 @capgo/capacitor-passkey의 구현 세부 사항을 위해 @capgo/capacitor-native-biometric Capgo의 Native 기능을 사용하는 @capgo/capacitor-native-biometric의 구현 세부 사항을 위해 두 단계 인증 두 단계 인증의 구현 세부 사항을 위해