facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 908 forks source link

Always getting result.isCancelled after pressing login button #689

Closed booboothefool closed 4 years ago

booboothefool commented 4 years ago

I am using 0.8.0 on iOS. I set up my Url Scheme, Info.plist, and AppDelegate.m. I am able to successfully use other features like Facebook Analytics. I have enabled Facebook Authentication in my Google Firebase and provided the credentials.

What else could I possibly be missing?

    facebookAuth = async () => {
        try {
            const result = await LoginManager.logInWithReadPermissions(['public_profile', 'email']);

            console.log({ result });

            if (result.isCancelled) {
                // handle this however suites the flow of your app
                // throw new Error('User cancelled request');
                alert('User cancelled request');
                return;
            }

            console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`);

            // get the access token
            const data = await AccessToken.getCurrentAccessToken();

            if (!data) {
                // handle this however suites the flow of your app
                throw new Error('Something went wrong obtaining the users access token');
            }

            // create a new firebase credential with the token
            const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);

            // login with credential
            const firebaseUserCredential = await firebase.auth().signInWithCredential(credential);

            console.warn(JSON.stringify(firebaseUserCredential.user.toJSON()))
        } catch (e) {
            console.error(e);
        }
    }
dharik commented 4 years ago

On RN .59.10, I upgraded to 0.10.0 and also upgraded FBSDK dependencies to a newer version to get passed this issue

    "react-native-fbsdk": "^0.10.0",
  pod 'FBSDKCoreKit', '5.6.0'
  pod 'FBSDKLoginKit', '5.6.0'
  pod 'FBSDKShareKit', '5.6.0'
booboothefool commented 4 years ago

@dharik Thanks it seems https://github.com/facebook/react-native-fbsdk/issues/646#issuecomment-538378016 is same problem.

What version of React Native are you on? It sounds like FBSDK 5.6.0 might require RN 0.60? Ugh I am on Expo 30 so it sounds like I may need to upgrade to Expo 36 before I can upgrade to FBSDK 5.6.0.

dharik commented 4 years ago

I'm on .59.10, not using Expo. 5.6.0 seems to work fine for me

booboothefool commented 4 years ago

Thanks I am able to confirm that I got it working with Expo 33, RN 0.59, and FBSDK 5.6.0.