Skip to content

Commit b28a720

Browse files
author
Chris Hackmann
committed
Expanded READMEs; adding CONTRIBUTING file; removed 'publish_actions' permission from sample app.
1 parent 0537012 commit b28a720

File tree

6 files changed

+197
-15
lines changed

6 files changed

+197
-15
lines changed

CONTRIBUTING.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Facebook welcomes contributions to our SDKs.
2+
3+
All contributors must sign a CLA (contributor license agreement) here:
4+
5+
https://developers.facebook.com/opensource/cla
6+
7+
To contribute on behalf of your employer, sign the company CLA
8+
To contribute on behalf of yourself, sign the individual CLA
9+
10+
All contributions:
11+
12+
1/ MUST be be licensed using the Apache License, Version 2.0
13+
2/ authors MAY retain copyright by adding their copyright notice to the appropriate flies
14+
15+
More information on the Apache License can be found here: http://www.apache.org/foundation/license-faq.html

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,31 @@ Functionality is provided through three separate npm packages so you never have
66
- `react-native-fbsdkshare`
77
- `react-native-fbsdklogin`
88

9+
# Usage
10+
Examples for using various components can be found in the readme files for the individual npm packages.
11+
912
## Running the Sample App
1013
- From the Sample folder, run `npm install`
1114
- Download and install the [Facebook SDK for iOS](https://developers.facebook.com/docs/ios).
1215
- Open NHSample.xcodeproj
13-
- Drag `FBSDKCoreKit.framework`, `FBSDKLoginKit.framework`, and `FBSDKShareKit.framework` into the Frameworks group in the XCode project navigator.
16+
- Drag `FBSDKCoreKit.framework`, `FBSDKLoginKit.framework`, and `FBSDKShareKit.framework` from the ~/Documents/FacebookSDK folder into the Frameworks group in the XCode project navigator.
1417
- Build and run the app to try it out.
1518

1619
## Installation
1720
- Download and install the [Facebook SDK for iOS](https://developers.facebook.com/docs/ios).
1821
- Follow the [getting started guide](https://developers.facebook.com/docs/ios/getting-started/) to link your project with the Facebook SDK frameworks and set up the app delegate.
1922
- Depending on what functionality you're looking to integrate, run any combination of the following:
20-
- `npm install react-native-fbsdkcore` for graph requests, app events, etc.
21-
- `npm install react-native-fbsdkshare` for share buttons, dialogs, etc.
22-
- `npm install react-native-fbsdklogin` for login button and manager.
23+
- `npm install react-native-fbsdkcore` for graph requests, app events, etc. `FBSDKCoreKit.framework` must be added to the project.
24+
- `npm install react-native-fbsdkshare` for share buttons, dialogs, etc. `FBSDKCoreKit.framework` and `FBSDKShareKit.framework` must be added to the project.
25+
- `npm install react-native-fbsdklogin` for login button and manager. `FBSDKCoreKit.framework` and `FBSDKLoginKit.framework` must be added to the project.
2326
- Open the Xcode project for your app.
2427
- Drag the folders prefixed with react-native-fbsdk from node_modules into the XCode project navigator.
2528

29+
### Troubleshooting
30+
- If you get a build error stating that one of the Facebook SDK files was not found -- eg. `FBSDKCoreKit/FBSDKCoreKit.h` -- check two things:x:
31+
- Ensure that the Facebook SDK frameworks have been added to the project.
32+
- Add the folder where the Facebook SDK was to the project's framework search path in Xcode. See Apple's [documentation on including frameworks](https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/IncludingFrameworks.html).
33+
2634
## License
2735
See the LICENSE file.
2836

Sample/Login.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var Login = React.createClass({
5050
}}
5151
onLogoutFinished={() => alert('Logged out.')}
5252
readPermissions={[]}
53-
publishPermissions={['publish_actions']}/>
53+
publishPermissions={[]}/>
5454
</View>
5555
);
5656
}

react-native-fbsdkcore/README.md

+43-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,52 @@
11
# react-native-fbsdkcore
22
A wrapper around the functionality from FBSDKCoreKit in the iOS Facebook SDK, supporting graph requests, app events, etc.
33

4-
## Example
5-
An example app is available from the [GitHub repository](https://github.com/facebook/react-native-fbsdk) for React Native FBSDK.
4+
## Usage
5+
6+
### Graph Requests
7+
```js
8+
var FBSDKCore = require('react-native-fbsdkcore');
9+
var {
10+
FBSDKGraphRequest,
11+
} = FBSDKCore;
12+
13+
// ...
14+
15+
// Create a graph request asking for friends with a callback to handle the response.
16+
var fetchFriendsRequest = new FBSDKGraphRequest((error, result) => {
17+
if (error) {
18+
alert('Error making request.');
19+
} else {
20+
// Data from request is in result
21+
}
22+
}, '/me/friends');
23+
// Start the graph request.
24+
fetchFriendsRequest.start();
25+
26+
// ...
27+
```
28+
29+
### App events
30+
```js
31+
var FBSDKCore = require('react-native-fbsdkcore');
32+
var {
33+
FBSDKAppEvents,
34+
} = FBSDKCore;
35+
36+
// ...
37+
38+
// Log a $15 purchase.
39+
FBSDKAppEvents.logPurchase(15, 'USD', null, null)
40+
41+
// ...
42+
```
43+
44+
## Sample App
45+
A sample app is available from the [GitHub repository](https://github.com/facebook/react-native-fbsdk) for React Native FBSDK.
646

747
## Installation
848
- Download and install the [Facebook SDK for iOS](https://developers.facebook.com/docs/ios).
9-
- Follow the [getting started guide](https://developers.facebook.com/docs/ios/getting-started/) to link your project with the Facebook SDK frameworks and set up the app delegate.
49+
- Follow the [getting started guide](https://developers.facebook.com/docs/ios/getting-started/) to link your project with the Facebook SDK frameworks and set up the app delegate. `FBSDKCoreKit.framework` must be added to the project.
1050
- run `npm install react-native-fbsdkcore`
1151
- Open the Xcode project for your app.
1252
- From Finder, drag the 'react-native-fbsdkcore' folder from node_modules into the XCode project navigator.

react-native-fbsdklogin/README.md

+65-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,74 @@
11
# react-native-fbsdkcore
22
A wrapper around the functionality from FBSDKLoginKit in the iOS Facebook SDK, supporting the login button and login manager.
33

4-
## Example
5-
An example app is available from the [GitHub repository](https://github.com/facebook/react-native-fbsdk) for React Native FBSDK.
4+
## Usage
5+
Below are usage examples for some of the components.
6+
7+
### Login Button
8+
```js
9+
var FBSDKLogin = require('react-native-fbsdklogin');
10+
var {
11+
FBSDKLoginButton,
12+
} = FBSDKLogin;
13+
14+
var Login = React.createClass({
15+
render: function() {
16+
return (
17+
<View>
18+
<FBSDKLoginButton
19+
onLoginFinished={(error, result) => {
20+
if (error) {
21+
alert('Error logging in.');
22+
} else {
23+
if (result.isCanceled) {
24+
alert('Login cancelled.');
25+
} else {
26+
alert('Logged in.');
27+
}
28+
}
29+
}}
30+
onLogoutFinished={() => alert('Logged out.')}
31+
readPermissions={[]}
32+
publishPermissions={['publish_actions']}/>
33+
</View>
34+
);
35+
}
36+
});
37+
```
38+
39+
### Login Manager
40+
```js
41+
var FBSDKLogin = require('react-native-fbsdklogin');
42+
var {
43+
FBSDKLoginManager,
44+
} = FBSDKLogin;
45+
46+
// ...
47+
48+
// Attempt a login using the native login dialog asking for default permissions.
49+
FBSDKLoginManager.setLoginBehavior(GlobalStore.getItem('behavior', 'native'));
50+
FBSDKLoginManager.logInWithReadPermissions([], (error, result) => {
51+
if (error) {
52+
alert('Error logging in.');
53+
} else {
54+
if (result.isCanceled) {
55+
alert('Login cancelled.');
56+
} else {
57+
alert('Logged in.');
58+
}
59+
}
60+
});
61+
62+
// ...
63+
```
64+
65+
## Sample App
66+
A sample app is available from the [GitHub repository](https://github.com/facebook/react-native-fbsdk) for React Native FBSDK.
667

768
## Installation
869
- Download and install the [Facebook SDK for iOS](https://developers.facebook.com/docs/ios).
9-
- Follow the [getting started guide](https://developers.facebook.com/docs/ios/getting-started/) to link your project with the Facebook SDK frameworks and set up the app delegate.
10-
- run `npm install react-native-fbsdklogin`
70+
- Follow the [getting started guide](https://developers.facebook.com/docs/ios/getting-started/) to link your project with the Facebook SDK frameworks and set up the app delegate. `FBSDKCoreKit.framework` and `FBSDKLoginKit.framework` must be added to the project.
71+
- run `npm install react-native-fbsdklogin`.
1172
- Open the Xcode project for your app.
1273
- From Finder, drag the 'react-native-fbsdkcore' folder from node_modules into the XCode project navigator.
1374

react-native-fbsdkshare/README.md

+61-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,70 @@
11
# react-native-fbsdkcore
22
A wrapper around the functionality from FBSDKShareKit in the iOS Facebook SDK, supporting the share button, share dialogs, etc.
33

4-
## Example
5-
An example app is available from the [GitHub repository](https://github.com/facebook/react-native-fbsdk) for React Native FBSDK.
4+
## Usage
5+
6+
### Share dialogs
7+
All of the dialogs included are used in a similar way, with differing content types.
8+
```js
9+
var FBSDKShare = require('react-native-fbsdkshare');
10+
var {
11+
FBSDKShareDialog,
12+
FBSDKShareLinkContent,
13+
} = FBSDKShare;
14+
15+
// ...
16+
17+
// Build up a shareable link.
18+
var linkContent = new FBSDKShareLinkContent('https://facebook.com', 'Wow, check out this great site!', 'Facebook.com', null);
19+
// Share the link using the native share dialog.
20+
FBSDKShareDialog.show(linkContent, (error, result) => {
21+
if (!error) {
22+
if (result.isCancelled) {
23+
alert('Share canceled.');
24+
} else {
25+
alert('Thanks for sharing!');
26+
}
27+
} else {
28+
alert('Error sharing.');
29+
}
30+
});
31+
32+
// ..
33+
```
34+
35+
### Share API
36+
Your app must have the publish_actions permission approved to share through the share API.
37+
```js
38+
var FBSDKShare = require('react-native-fbsdkshare');
39+
var {
40+
FBSDKShareAPI,
41+
FBSDKSharePhoto,
42+
FBSDKSharePhotoContent,
43+
} = FBSDKShare;
44+
45+
// ...
46+
47+
// Build up a shareable photo, where 'cat.png' is included in the project. A data URI encoding the image can also be passed.
48+
var photo = new FBSDKSharePhoto('cat.png', true);
49+
var photoContent = new FBSDKSharePhotoContent([photo]);
50+
// Share using the share API.
51+
FBSDKShareAPI.share(photoContent, "/me", "Check out this cat!", (error, result) => {
52+
if (error) {
53+
alert('Error sharing');
54+
} else {
55+
alert('Shared successfully');
56+
}
57+
});
58+
59+
// ...
60+
```
61+
62+
## Sample App
63+
A sample app is available from the [GitHub repository](https://github.com/facebook/react-native-fbsdk) for React Native FBSDK.
664

765
## Installation
866
- Download and install the [Facebook SDK for iOS](https://developers.facebook.com/docs/ios).
9-
- Follow the [getting started guide](https://developers.facebook.com/docs/ios/getting-started/) to link your project with the Facebook SDK frameworks and set up the app delegate.
67+
- Follow the [getting started guide](https://developers.facebook.com/docs/ios/getting-started/) to link your project with the Facebook SDK frameworks and set up the app delegate. `FBSDKCoreKit.framework` and `FBSDKShareKit.framework` must be added to the project.
1068
- run `npm install react-native-fbsdkshare`
1169
- Open the Xcode project for your app.
1270
- From Finder, drag the 'react-native-fbsdkcore' folder from node_modules into the XCode project navigator.

0 commit comments

Comments
 (0)