loginWithKakao method
- BuildContext context,
- {LoginUiMode uiMode = LoginUiMode.auto,
- AccountLoginParams? accountParams,
- List<
String> ? channelPublicIds, - List<
String> ? serviceTerms, - String? nonce}
KO: 카카오톡으로 로그인과 카카오계정으로 로그인 중 하나를 선택할 수 있는 화면 제공
uiMode에 로그인 선택 화면 모드 전달
accountParams에 카카오계정으로 로그인 기능을 위한 설정 전달
channelPublicIds에 카카오톡 채널 프로필 ID 전달
serviceTerms 서비스 약관 목록 전달
ID 토큰 재생 공격 방지를 위한 검증 값, 임의의 문자열은 nonce에 전달
EN: Provides a screen where users can choose between logging in with Kakao Talk or Kakao Account.
Pass the login selection screen mode to uiMode
Pass the settings for the Kakao Account login feature to accountParams
Pass list of Kakao Talk Channel IDs to channelPublicIds
Pass list of service terms to serviceTerms
Pass a random string to prevent replay attacks to nonce
Implementation
Future<OAuthToken> loginWithKakao(
BuildContext context, {
LoginUiMode uiMode = LoginUiMode.auto,
AccountLoginParams? accountParams,
List<String>? channelPublicIds,
List<String>? serviceTerms,
String? nonce,
}) async {
if (kIsWeb) {
throw KakaoClientException(
ClientErrorCause.notSupported,
'loginWithKakao() is not supported on web platform.',
);
}
final loginMethod = await showModalBottomSheet(
context: context,
constraints: BoxConstraints.fromViewConstraints(
const ViewConstraints(
maxWidth: double.infinity,
minHeight: 246,
),
),
isScrollControlled: true,
builder: (_) => LoginBridgeBottomSheet(
uiMode: uiMode,
onTalkLoginPressed: () async => Navigator.of(context).pop('talk'),
onAccountLoginPressed: () async => Navigator.of(context).pop('account'),
),
);
if (loginMethod == 'talk') {
return await loginWithKakaoTalk(
channelPublicIds: channelPublicIds,
serviceTerms: serviceTerms,
nonce: nonce,
);
} else if (loginMethod == 'account') {
return await loginWithKakaoAccount(
prompts: accountParams?.prompts,
channelPublicIds: channelPublicIds,
serviceTerms: serviceTerms,
loginHint: accountParams?.loginHint,
nonce: nonce,
);
}
throw KakaoClientException(ClientErrorCause.cancelled, 'User Cancelled');
}