GoldenOwlAsia / react-native-twitter-signin

MIT License
167 stars 303 forks source link

App is crashing on pressing cancel, without signing in #157

Closed yash-atreya closed 4 years ago

yash-atreya commented 4 years ago

This is happening in Android and iOS. I get the error: Error: Twitter signing error. I can't figure out what is going on.

I'm using react-native-twitter-signin with react-native-firebase v6.

Versions

react-native: 0.61.4
react-native-twitter-signin: 1.1.1
@react-native-firebase/auth: 6.7.1

Code:

import * as React from 'react';
import {View, Text, Button} from 'react-native';
import auth from '@react-native-firebase/auth';
import {NativeModules} from 'react-native';
const {RNTwitterSignIn} = NativeModules;

import Ionicons from 'react-native-vector-icons/Ionicons';

const SignInScreen = ({navigation}) => {
  return (
    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <Text>SignIn</Text>
      <Ionicons name="md-person" />
      <Button onPress={TwitterSignIn} title="Log In" />
    </View>
  );
};

const TwitterSignIn = async () => {
  try {
    var {authToken, authTokenSecret} = await RNTwitterSignIn.logIn();
  } catch (e) {
    console.log('Error retrieving tokens ', e);
  }

  const credential = auth.TwitterAuthProvider.credential(
    authToken,
    authTokenSecret,
  );

  auth()
    .signInWithCredential(credential)
    .then(user => {
      console.log('Successfully Signed In With Twitter');
      console.log('User ', JSON.stringify(user, null, 2));
    })
    .catch(e => {
      console.log('Error Signing up with Twitter: ', e);
    });
};

export default SignInScreen;
yash-atreya commented 4 years ago

Solved this !