How to use the react-native-square-reader-sdk.authorizeAsync function in react-native-square-reader-sdk

To help you get started, we’ve selected a few react-native-square-reader-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github square / react-native-square-reader-sdk / reader-sdk-react-native-quickstart / app / screens / AuthorizingScreen.js View on Github external
async authorize(navigation) {
    const authCode = navigation.getParam('authCode', '');
    if (!authCode) {
      Alert.alert('Error: empty auth code');
      navigation.goBack();
      return;
    }
    try {
      await authorizeAsync(authCode);
      this.props.navigation.navigate('Checkout');
    } catch (ex) {
      let errorMessage = ex.message;
      switch (ex.code) {
        case AuthorizeErrorNoNetwork:
          // Remind connecting to network and retry
          Alert.alert(
            'Network error',
            ex.message,
            [
              { text: 'Retry', onPress: () => this.authorize(navigation) },
              { text: 'Cancel', onPress: () => navigation.navigate('Authorize'), style: 'cancel' },
            ],
          );
          break;
        case UsageError: