react-native-apple-authentication返回appleAuthAndroid的空对象

时间:2020-11-02 02:23:25

标签: react-native react-native-android apple-sign-in invertase

我正在尝试在@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;
      
  }
};

0 个答案:

没有答案