add basic tests for rect-native-fbsdk

remove unneeded namespace export

fix typo in AppEventsFlushBehavior

remove top level namespace

Also fix typos.
This commit is contained in:
Ifiok Jr 2017-07-09 16:45:37 +01:00
parent 8869554ffe
commit 60dce20e91
3 changed files with 1155 additions and 1053 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,107 @@
import * as React from 'react';
import * as FBSDK from 'react-native-fbsdk';
import { View } from 'react-native';
import render from '../react-dom/index';
const {
LoginButton,
AccessToken
LoginButton,
AccessToken,
LoginManager,
ShareDialog,
AppEventsLogger,
GraphRequest,
GraphRequestManager,
} = FBSDK;
class Login extends React.Component {
render() {
return (
<View>
<LoginButton
publishPermissions={["publish_actions"]}
onLoginFinished={
(error, result) => {
if (error) {
alert("login has error: " + result.error);
} else if (result.isCancelled) {
alert("login is cancelled.");
} else {
AccessToken.getCurrentAccessToken().then(
(data) => {
alert(data.accessToken.toString())
}
);
}
}
}
onLogoutFinished={() => alert("logout.")}/>
</View>
);
}
export class Login extends React.Component {
render() {
return (
<View>
<LoginButton
publishPermissions={["publish_actions"]}
onLoginFinished={
(error, result) => {
if (error) {
alert("login has error: " + result.error);
} else if (result.isCancelled) {
alert("login is cancelled.");
} else {
AccessToken.getCurrentAccessToken().then(
(data) => {
if (data) {
alert(data.accessToken.toString());
}
}
);
}
}
}
onLogoutFinished={() => alert("logout.")}
/>
</View>
);
}
}
// Attempt a login using the Facebook login dialog asking for default permissions.
LoginManager.logInWithReadPermissions(['public_profile']).then(
(result) => {
if (result.isCancelled) {
alert('Login cancelled');
} else {
alert(`Login success with permissions: ${result.grantedPermissions}`);
}
},
(error) => {
alert(`Login fail with error: ${error}`);
}
);
// Build up a shareable link.
const shareLinkContent: FBSDK.ShareLinkContent = {
contentType: 'link',
contentUrl: "https://facebook.com",
contentDescription: 'Wow, check out this great site!',
};
// Share the link using the share dialog.
export const shareLinkWithShareDialog = (): void => {
ShareDialog.canShow(shareLinkContent).then(
(canShow) => {
if (canShow) {
return ShareDialog.show(shareLinkContent);
}
}
).then(
(result) => {
if (result.isCancelled) {
alert('Share cancelled');
} else {
alert(`Share success with postId: ${result.postId}`);
}
},
(error: Error) => {
alert(`Share fail with error: ${error}`);
}
);
};
const obj = { param: 'value' };
AppEventsLogger.logPurchase(15, 'USD', obj);
const responseInfoCallback: FBSDK.GraphRequestCallback = (error, result) => {
if (error) {
alert(`Error fetching data: ${error}`);
} else {
alert(`Success fetching data: ${result}`);
}
};
// Create a graph request asking for user information with a callback to handle the response.
const infoRequest = new GraphRequest(
'/me',
null,
responseInfoCallback,
);
// Start the graph request.
new GraphRequestManager().addRequest(infoRequest).start();

View File

@ -15,10 +15,10 @@
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
"jsx": "react-native"
},
"files": [
"index.d.ts",
"react-native-elements-tests.tsx"
"react-native-fbsdk-tests.tsx"
]
}