I successfully managed to create a native component that successfully logins a user into Facebook. So, in my react-native app, I've got the access token and the userId. Now, I'd like to use Facebook SDK (for example, the Graph API) to access to some basic infos (profile name, profile picture, etc.) and to do basic things (share a post, etc.)
At this point I'm quite lost: how can I do that? Can I use the fetch API? Do I need to add some node plugin to my app (I was looking for this: https://github.com/Thuzi/facebook-node-sdk)?
You can make a request like this using the fetch API where query can be something like https://graph.facebook.com/me?access_token=token_you_got
fetch('https://graph.facebook.com/me?access_token=token_you_got')
.then(response => response.json())
.then(json => this._handleResponse(json.response))
.catch(error =>
this.setState({
isLoading: false,
message: 'Something bad happened ' + error
}));
More information here: http://www.raywenderlich.com/99473/introducing-react-native-building-apps-javascript
I know its a little late to the party but for future reference to anyone who is going to integrate with Facebook with React-Native should consider using this wrapper around the ios Facebook SDK.
https://github.com/facebook/react-native-fbsdk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With