本文最后更新于 2024年5月16日 上午
ReactNative
苹果账号第三方登录,下面我们将对于在RN
中配置使用Apple
登录的配置和使用说明。
安装
1
| npm i @invertase/react-native-apple-authentication
|
使用
在业务逻辑中我们自定义登录模块
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| const handleAppleLogin = async () => { try { const appleAuthRequestResponse = await appleAuth.performRequest({ requestedOperation: appleAuth.Operation.LOGIN, requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME] })
if (!appleAuthRequestResponse.identityToken) { throw 'Apple Sign-In failed - no identify token returned' }
const { identityToken, nonce, email, user, fullName } = appleAuthRequestResponse console.log('appleAuthRequestResponse', appleAuthRequestResponse)
Alert.alert(nonce, JSON.stringify(identityToken)) } catch (err) {} }
|