I'm trying to use the react-native-fbsdk to get a user's access token. Upon calling the logInWithReadPermissions method, I keep getting an error that says "undefined is not an object (evaluating 'LoginManager.logInWithReadPermissions')"
I installed the npm dependency and imported it:
import { LoginManager, AccessToken } from 'react-native-fbsdk'
The class method loginWithFacebook looks like this:
logInWithFacebook = () => {
LoginManager.logInWithReadPermissions([ 'public_profile', 'user_friends' ]).then(
(result) => {
if(result.isCanceled) {
alert('Login cancelled')
} else {
AccessToken.getCurrentAccessToken().then(({ accessToken }) => {
console.log('Access Token : ', accessToken)
})
}
},
(error) => {
console.error('error : ', error)
}
)
}
I've tried clearing my cache, moving the project to my Documents directory, re-installing all npm packages... and still, I keep getting this error. Click here to see the Expo debugging screen.
Any suggestions would be greatly appreciated. Thank you!
You can not use libraries that require native code configuration via react-native link with a standard Expo project. In order to use said libraries, you need to detach and use ExpoKit. Here are the docs regarding ExpoKit: https://docs.expo.io/versions/latest/guides/detach.html
With that said, we do have a Facebook API that may do what you need that is built into the Expo SDK. https://docs.expo.io/versions/latest/sdk/facebook.html