Apple Sign In Migration
이 콘텐츠는 아직 귀하의 언어로 제공되지 않습니다.
Migration Guide from @capacitor-community/apple-sign-in to @capgo/capacitor-social-login
Installation
-
Remove the old package:
Terminal window npm uninstall @capacitor-community/apple-sign-in -
Install the new package:
Terminal window npm install @capgo/capacitor-social-loginnpx cap sync
Code Changes
Import Changes
import { SignInWithApple } from '@capacitor-community/apple-sign-in';import { SocialLogin } from '@capgo/capacitor-social-login';
Initialization
// No initialization needed in old packageawait SocialLogin.initialize({ apple: {} // Basic iOS configuration});
// For Android, you need additional configuration:await SocialLogin.initialize({ apple: { clientId: 'YOUR_SERVICE_ID', // Service ID from Apple Developer Portal redirectUrl: 'https://your-backend.com/callback' // Your backend callback URL. Please note that this URL behaves differently than in @capacitor-community/apple-sign-in. Please refer to the documentation for more details. }});
Sign In
const result = await SignInWithApple.authorize({ clientId: 'com.your.app', redirectURI: 'https://your-app.com/callback', scopes: 'email name', state: '12345', nonce: 'nonce'});
const result = await SocialLogin.login({ provider: 'apple', options: { // Optional: Add scopes if needed scopes: ['email', 'name'], nonce: 'nonce' }});
Response Type Changes
The response object structure has changed. Here’s how to handle the new response:
// Old response typeinterface AppleSignInResponse { response: { user: string; email: string | null; givenName: string | null; familyName: string | null; identityToken: string | null; authorizationCode: string | null; };}
// New response typeinterface SocialLoginResponse { provider: 'apple'; result: { accessToken: { token: string; expiresIn?: number; refreshToken?: string; } | null; idToken: string | null; profile: { user: string; email: string | null; givenName: string | null; familyName: string | null; }; };}
Checking Login Status
// Not available in old packageconst status = await SocialLogin.isLoggedIn({ provider: 'apple'});
Logout
// Not available in old packageawait SocialLogin.logout({ provider: 'apple'});
Platform Specific Changes
iOS Setup
- The iOS setup remains largely the same. You still need to:
- Enable “Sign In with Apple” capability in Xcode
- Configure your app in the Apple Developer Portal
- No additional code changes required for iOS
Android Setup
The new plugin provides Android support out of the box, but requires additional setup:
- Create a Services ID in the Apple Developer Portal
- Configure a web authentication endpoint
- Set up your Android app to handle the OAuth flow
For detailed Android setup instructions, please refer to the Android Setup Guide.
Additional Features
The new plugin offers several advantages:
- Built-in Android support through web-based authentication
- Unified API for multiple social login providers (Google, Facebook)
- Persistent login state management
- TypeScript support with better type definitions
- Active maintenance and community support
Breaking Changes
- The initialization step is now required
- Response object structure has changed
- Android implementation requires a backend service
- Token refresh handling is different
- Error handling and error types have changed
For more detailed setup instructions, please refer to the official documentation.