Muntaner
Muntaner

Reputation: 105

React-native app and Facebook SDK

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)?

Upvotes: 4

Views: 2999

Answers (2)

Russell Maxfield
Russell Maxfield

Reputation: 968

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

Upvotes: 1

Shireesh Asthana
Shireesh Asthana

Reputation: 724

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

Upvotes: 7

Related Questions