invertase / react-native-apple-authentication

A React Native library providing support for Apple Authentication on iOS and Android.
Other
1.42k stars 223 forks source link

'appleAuthAndroid.Error' is sometimes missing on iOS. "Cannot read property 'SIGNIN_CANCELLED' of undefined" #271

Closed jwoodmansey closed 2 years ago

jwoodmansey commented 2 years ago

Hi,

We seem to be seeing a lot of Cannot read property 'SIGNIN_CANCELLED' of undefined in production in our iOS app. Is there some specific config required to prevent this? We can do an undefined check or wrap in a Platform.OS but I didn't see this in the example code.

We use the following code to catch cancelled errors:

import {
  AppleRequestResponseFullName,
  appleAuth,
  appleAuthAndroid,
} from '@invertase/react-native-apple-authentication';

...

      if (
        error.code === appleAuth.Error.CANCELED ||
        error.code === appleAuthAndroid.Error.SIGNIN_CANCELLED
      ) {
        return undefined;
      }
      throw error;

So it looks like appleAuthAndroid.Error is somehow missing.

package.json: "@invertase/react-native-apple-authentication": "^2.1.5", .... "react-native": "0.67.1"

Thanks in advance!

jwoodmansey commented 2 years ago

Turns out we weren't calling appleAuthAndroid.configure() on iOS devices, so that'll likely be why.