I am using the react-native-fbsdk 0.8.0 with React-Native 0.57.4 and getting the error:
Login failed with error: the operation couldn't be completed. (com.facebook.sdk.login error 308).
about 30% of the time. I have tried with both LoginButton and LoginManager.
Also tried v0.9 and v0.7 of react-native-fbsdk, with the same result.
With LoginManager, I tried the LoginManager.logOut() trick also that I've seen posted by others (i.e. https://medium.com/@crysfel/error-when-login-with-facebook-sdk-react-native-c06a33078102)
I have the Keychain Sharing capability turned on.
I have followed all of the instructions at https://github.com/facebook/react-native-fbsdk including setting LSApplicationQueriesSchemes
Any suggestions for what I should try next if its working fine 2/3 times?
My login button code:
<LoginButton
style={[styles.button, styles.facebook]}
readPermissions={[
'public_profile',
'user_birthday',
'user_gender',
'email'
]}
onLoginFinished={(error, result) => {
if (error) {
alert('Login failed with error: ' + error.message);
} else if (result.isCancelled) {
alert('Login was cancelled');
} else {
// alert(
// 'Login was successful with permissions: ' +
// result.grantedPermissions
// );
AccessToken.getCurrentAccessToken().then(data => {
console.log(data.accessToken.toString());
this.fetchProfile().then(profile =>
this.checkOrAddUser(profile)
);
});
}
}}
onLogoutFinished={() => alert('User logged out')}
/>
And my LoginManager code:
handleLogin = () => {
LoginManager.logInWithReadPermissions([
'public_profile',
'user_birthday',
'user_gender',
'email'
]).then(
result => {
if (result.isCancelled) {
console.log(result);
console.log('Login cancelled');
} else {
console.log(
'Login success with permissions: ' +
result.grantedPermissions.toString()
);
console.log('result is ' + result);
AccessToken.getCurrentAccessToken().then(data => {
console.log(data.accessToken.toString());
this.fetchProfile().then(profile => this.checkOrAddUser(profile));
});
}
},
function(error) {
console.log(error);
console.log('Login fail with error: ' + error.message);
LoginManager.logOut();
alert('Login failed. Try again.');
}
);
};