코딩/React Native
[RN]애플 로그인(react-native-apple-authentication)
카슈밀
2025. 2. 22. 03:31
반응형
https://github.com/invertase/react-native-apple-authentication
GitHub - invertase/react-native-apple-authentication: A React Native library providing support for Apple Authentication on iOS a
A React Native library providing support for Apple Authentication on iOS and Android. - invertase/react-native-apple-authentication
github.com
방법은 어렵지 않다.
// App.js
import React from 'react';
import { View } from 'react-native';
import { AppleButton, appleAuth } from '@invertase/react-native-apple-authentication';
async function onAppleButtonPress() {
const {identityToken, fullName} = await appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,
// Note: it appears putting FULL_NAME first is important, see issue #293
requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
});
if (identityToken) {
// 통신내용 블라 블라~
}
}
function App() {
return (
<View>
<AppleButton
buttonStyle={AppleButton.Style.WHITE}
buttonType={AppleButton.Type.SIGN_IN}
style={{
width: 160, // You must specify a width
height: 45, // You must specify a height
}}
onPress={() => onAppleButtonPress()}
/>
</View>
);
}
728x90