I am trying to implement Apple Authentication in react native app. But I am getting error saying Error: RNAppleAuth.AppleAuthRequestOptions 'requestedOperation' must be a value of AppleAuthRequestOperation.
I have implemented it in the same way as given in this guide https://github.com/invertase/react-native-apple-authentication
Still, I am getting this error and I am not able the solution for this.
My code:
import { appleAuth } from "@invertase/react-native-apple-authentication";
import Axios from "axios";
export default function AppleSignButton(props) {
/**
* CallBack function for the button.
*/
const onAppleButtonPress = async () => {
// Make a request to apple.
const appleAuthRequestResponse = await appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN.LOGIN,
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],
});
// Get the credential for the user.
const credentialState = await appleAuth.getCredentialStateForUser(
appleAuthRequestResponse.user
);
// If the Auth is authorized, we call our API and pass the authorization code.
if (credentialState === appleAuth.State.AUTHORIZED) {
console.log(appleAuthRequestResponse.authorizationCode);
Axios.post("https://test****/api/apple", {
token: appleAuthRequestResponse.authorizationCode,
}).then((res) => {
if (res?.data?.user) {
Alert.alert(
"Number of connections: " + res.data.user.nbOfConnections.toString()
);
}
});
}
};
I need to implement Apple signup & sign-in methods in react native app. How can I make this work?