메인 콘텐츠로 건너뛰기

Facebook 로그인 이주 @capgo/social-login으로

@GitHub

이 가이드는 @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.

을 지원하며 여러 가지 사회 제공자를 지원하고 TypeScript 지원을 개선하고 기능을 강화합니다.

설치
  1. “설치”라는 제목을 가진 섹션

    터미널 창
    npm uninstall @capacitor-community/facebook-login
  2. 새 패키지를 설치하세요:

    터미널 창
    npm install @capgo/capacitor-social-login
    npx cap sync

Code 변경 사항

Code 변경 사항 섹션

변경 사항 가져오기

변경 사항 가져오기 섹션
import { FacebookLogin } from '@capacitor-community/facebook-login';
import { SocialLogin } from '@capgo/capacitor-social-login';

Key Changecode:에 새로운 패키지는 명시적인 설정이 필요합니다.

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

로그인 메소드는 이제 제공자 매개 변수를 받을 수 있습니다.

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

Response Type Changes

Response Type Changes 섹션

응답 구조는 더 광범위한 프로필 객체로 현대화되었습니다.

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

Key Differences:

  • __CAPGO_KEEP_0__ 현재 응답에는 인증 제공자의 provider field identifying the authentication provider
  • __CAPGO_KEEP_1__ 더 자세한 profile object with additional user information
  • __CAPGO_KEEP_2__ 모든 사회 로그인 제공자에서 일관된 구조
const result = await FacebookLogin.getCurrentAccessToken();
const isLoggedIn = result && result.accessToken;
const status = await SocialLogin.isLoggedIn({
provider: 'facebook'
});
const isLoggedIn = status.isLoggedIn;

__CAPGO_KEEP_4__ 클립보드에 복사

Section titled “Logout”
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 인증을 위해 클라이언트 토큰이 필요합니다.

  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 configuration이 여전히 동일합니다:
<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. __CAPGO_KEEP_0__ - 추가 설정이 필요합니다
  4. 다른 메서드 이름과 매개 변수 구조 - 제공자 기반 접근 방식
  5. 오류 처리 및 오류 유형이 변경되었습니다 - 더 자세한 오류 정보

주요 이점

주요 이점

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

  • 통합 API 다수의 사회 제공자 (Google, Apple, Facebook)across
  • TypeScript 지원이 향상되었습니다. with better type definitions
  • 개인 정보가 더 자세히 제공된 프로필 데이터 사용자 정보가 더 많습니다
  • 활발한 유지 보수 및 커뮤니티 지원
  • 모든 제공자에서 일관된 오류 처리 토큰 관리에 더 나은 만료 처리
  • 설정 지침에 대한 자세한 설명을 위해 공식 문서를 참조하십시오 Facebook 로그인 마이그레이션에서 @__CAPGO_KEEP_0__/social-login로 계속 진행하십시오

제목 ‘Facebook 로그인 마이그레이션에서 @__CAPGO_KEEP_0__/social-login로 계속 진행하십시오’ Facebook 로그인 마이그레이션에서 @__CAPGO_KEEP_0__/social-login로 계속 진행하십시오.

제목 ‘Facebook 로그인 마이그레이션에서 @capgo/social-login로 계속 진행하십시오’

Facebook 로그인 마이그레이션에서 @capgo/social-login로 계속 진행하십시오

만약에 Facebook 로그인 이주를 @capgo/social-login 에서 인증 및 계정 흐름을 계획하고 연결하려면 Using @capgo/capacitor-social-login 을 사용하여 native 기능을 사용하는 @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 구현 세부 정보에서, 두 단계 인증 __CAPGO_KEEP_0__의 두 단계 인증 구현 세부 정보에 대해.