[Flutter] 애플 로그인 체크 리스트

애플로그인 을 안드로이드에서 구현 하는 방법을 적어보겠습니다. 아래 체크리스트 중에 헷깔리는 부분을 위주로 적어보겠습니다. 자세한 내용은 맨 아래 링크를 참조해주세요

애플 로그인 체크리스트

  1. account>Identifiers – App id 생성
  2. account>keys – 애플 로그인 key 생성, 다운로드
  3. account>Identifiers – Service id 생성
  4. xcode – Sign in with Apple 추가
  5. Android Manifest.xml – callback Activity 추가
  6. glitch – remix your own
  7. glitch – Team id, Service id, Bundle id, Key id, key contents 입력
  8. glitch – android package 명 입력
  9. account>identifiers – serviceId에서 domain 및 return url, 글리치 것으로 입력
  10. 애플 로그인 flutter 코드 입력

App id 생성

애플 로그인 key 생성, 다운로드

Android manifest.xml 파일에 콜백 activity추가

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.">
   <application
        android:label=""
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        .
        .
        .
        <!-- 추가 -->
        <activity
          android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
          android:exported="true">
             <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="signinwithapple" />
                <data android:path="callback" />
             </intent-filter>
        </activity>
        .
        .
        .
    </application>
</manifest>

애플 로그인 코드

void signInWithApple() async {
    try {
      final AuthorizationCredentialAppleID credential =
          await SignInWithApple.getAppleIDCredential(
        scopes: [
          AppleIDAuthorizationScopes.email,
          AppleIDAuthorizationScopes.fullName,
        ],
        webAuthenticationOptions: WebAuthenticationOptions(
          clientId: "Apple Developer 에서 설정한 Service ID",
          redirectUri: Uri.parse(
            "Apple Developer 에서 설정한 redirectUri",
          ),
        ),
      );

      print('credential.state = $credential');
      print('credential.state = ${credential.email}');
      print('credential.state = ${credential.userIdentifier}');

      setState(() {
        _loginPlatform = LoginPlatform.apple;
      });
    } catch (error) {
      print('error = $error');
    }
  }

아래 링크 참조

https://pub.dev/packages/sign_in_with_apple