This npm module is used for authentication using Apple id in React Native apps. Apple sign-in only works with IOS platform and the setup guide considers the same.
To install the module, run the following command in your project directory:
$ npm install --save react-native-apple-authentication
From react-native version 0.60 we don't need to link any third party module separately but if you found it has not been included with your project then you can run the following:
$ react-native link react-native-apple-authentication
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-apple-authentication
and add AppleSignIn.xcodeproj
libAppleSignIn.a
to your project's Build Phases
➜ Link Binary With Libraries
Cmd+R
)XCode 11
and iOS 13
. Although you can install XCode 11 on Mac Mojave 10.14.14 and later. Signing & Capabilities
tab so Xcode can create a provisioning profile that. If you've already created project and provisioning profile then ignore this.Sign In with Apple capability
in your project. This will add an entitlement that lets your app use Sign In with Apple.AUTH_ALERT_SIGN_UP_NOT_COMPLETED
error message. Signing in won't work in your application until you create a key with Sign in with Apple enabled in your developer account.Auth Key
with Sign In with Apple. on your developer account.Prop | Value |
---|---|
buttonText | Optional |
buttonStyle | Optional |
textStyle | Optional |
Function | Value |
---|---|
callBack | Required |
import { SignInWithAppleButton } from 'react-native-apple-authentication'
export default class App extends React.Component{
render(){
return(
<View style = {styles.container}>
{SignInWithAppleButton({
buttonStyle: styles.appleBtn,
callBack: this.appleSignIn,
buttonText: "Sign Up With Apple",
})}
</View>)
}
appleSignIn = (result) => {
console.log('Resssult',result);
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
},
appleBtn: { height: 44, width: 200 }
});