我正在尝试在@invertase/react-native-apple-authentication": "2.1.0"
上使用react-native@0.61.5
在Android上实现Apple auth。 appleAuth
在iOS上运行良好,但appleAuthAndroid
只是返回一个空对象。
import { appleAuth, appleAuthAndroid } from '@invertase/react-native-apple-authentication';
export const loginWithAppleAndroid = () => async () => {
// performs login request
try {
console.log('appleAuth',appleAuth) //logs full appleAuth object as expected
console.log('appleAuthAndroid',appleAuthAndroid) //logs an empty object
const rawNonce = uuidv4();
const state = uuidv4();
// Configure the request
appleAuthAndroid.configure({
// The Service ID you registered with Apple
clientId: ' myID',
// Return URL added to your Apple dev console. We intercept this redirect, but it must still match
// the URL you provided to Apple. It can be an empty route on your backend as it's never called.
redirectUri: 'https://myURI.com',
// The type of response requested - code, id_token, or both.
responseType: appleAuthAndroid.ResponseType.ALL,
// The amount of user information requested from Apple.
scope: appleAuthAndroid.Scope.ALL,
// Random nonce value that will be SHA256 hashed before sending to Apple.
nonce: rawNonce,
// Unique state value used to prevent CSRF attacks. A UUID will be generated if nothing is provided.
state,
});
// Open the browser window for user sign in
const response = await appleAuthAndroid.signIn();
// Send the authorization code to your backend for verification
return response
} catch (error) {
console.warn(appleAuth.State);
throw error;
}
};