Created
April 9, 2021 08:14
-
-
Save zendevil/704508e46017910cfcdfda28768e89ec to your computer and use it in GitHub Desktop.
appleAuth js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { appleAuth } from '@invertase/react-native-apple-authentication'; | |
async function onAppleButtonPress() { | |
// performs login request | |
const appleAuthRequestResponse = await appleAuth.performRequest({ | |
requestedOperation: appleAuth.Operation.LOGIN, | |
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME], | |
}); | |
// get current authentication state for user | |
// /!\ This method must be tested on a real device. On the iOS simulator it always throws an error. | |
const credentialState = await appleAuth.getCredentialStateForUser(appleAuthRequestResponse.user); | |
// use credentialState response to ensure the user is authenticated | |
if (credentialState === appleAuth.State.AUTHORIZED) { | |
// user is authenticated | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment