애플로그인 을 안드로이드에서 구현 하는 방법을 적어보겠습니다. 아래 체크리스트 중에 헷깔리는 부분을 위주로 적어보겠습니다. 자세한 내용은 맨 아래 링크를 참조해주세요
애플 로그인 체크리스트
- account>Identifiers – App id 생성
- account>keys – 애플 로그인 key 생성, 다운로드
- account>Identifiers – Service id 생성
- xcode – Sign in with Apple 추가
- Android Manifest.xml – callback Activity 추가
- glitch – remix your own
- glitch – Team id, Service id, Bundle id, Key id, key contents 입력
- glitch – android package 명 입력
- account>identifiers – serviceId에서 domain 및 return url, 글리치 것으로 입력
- 애플 로그인 flutter 코드 입력
App id 생성
![](https://lucasblog.kr/wp-content/uploads/2024/07/image-3-1024x630.png)
![](https://lucasblog.kr/wp-content/uploads/2024/07/image-4-1024x564.png)
애플 로그인 key 생성, 다운로드
![](https://lucasblog.kr/wp-content/uploads/2024/07/image-5-1024x215.png)
![](https://lucasblog.kr/wp-content/uploads/2024/07/image-6-1024x389.png)
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');
}
}
아래 링크 참조