Skip to content

Commit

Permalink
docs: this is the actual example app, auto-generated from refresh-exa…
Browse files Browse the repository at this point in the history
…mple.sh

The contents here will change periodically. Only App.js and README.md are preserved when re-generated
  • Loading branch information
mikehardy committed Jul 6, 2021
1 parent 6fe0aa4 commit 1ec6d85
Show file tree
Hide file tree
Showing 60 changed files with 9,361 additions and 0 deletions.
6 changes: 6 additions & 0 deletions RNFBSDKExample/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
4 changes: 4 additions & 0 deletions RNFBSDKExample/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
66 changes: 66 additions & 0 deletions RNFBSDKExample/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
node_modules/react-native/interface.js
node_modules/react-native/flow/

[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

exact_by_default=true

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
unnecessary-invariant=warn
signature-verification-failure=warn

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.137.0
3 changes: 3 additions & 0 deletions RNFBSDKExample/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
59 changes: 59 additions & 0 deletions RNFBSDKExample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
7 changes: 7 additions & 0 deletions RNFBSDKExample/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};
1 change: 1 addition & 0 deletions RNFBSDKExample/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
83 changes: 83 additions & 0 deletions RNFBSDKExample/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Facebook.
*
* As with any software that integrates with the Facebook platform, your use of
* this software is subject to the Facebook Developer Principles and Policies
* [http://developers.facebook.com/policy/]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @format
* @flow
*/

import React, {Component} from 'react';
import {Alert, StyleSheet, Text, TouchableHighlight, View} from 'react-native';
import {LoginButton, Settings, ShareDialog} from 'react-native-fbsdk-next';

const SHARE_LINK_CONTENT = {
contentType: 'link',
contentUrl: 'https://www.facebook.com/',
};

// Ask for consent first if necessary
// Possibly only do this for iOS if no need to handle a GDPR-type flow
Settings.initializeSDK();

export default class App extends Component<{}> {
_shareLinkWithShareDialog = async () => {
const canShow = await ShareDialog.canShow(SHARE_LINK_CONTENT);
if (canShow) {
try {
const {isCancelled, postId} = await ShareDialog.show(
SHARE_LINK_CONTENT,
);
if (isCancelled) {
Alert.alert('Share cancelled');
} else {
Alert.alert('Share success with postId: ' + postId);
}
} catch (error) {
Alert.alert('Share fail with error: ' + error);
}
}
};

render() {
return (
<View style={styles.container}>
<LoginButton
onLoginFinished={(error, data) => {
Alert.alert(JSON.stringify(error || data, null, 2));
}}
/>
<TouchableHighlight onPress={this._shareLinkWithShareDialog}>
<Text style={styles.shareText}>Share link with ShareDialog</Text>
</TouchableHighlight>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
shareText: {
fontSize: 20,
margin: 10,
},
});
27 changes: 27 additions & 0 deletions RNFBSDKExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# react-native-fbsdk-next example

This example is extremely basic but hopefully still useful.

You run it by cloning the main repo, and running `yarn` then `yarn example:android` or `yarn example:ios`

The example currently validates these things:

## Successful project integration

- the module should successfully integrate with current react-native: install and run, android and ios

## Basic Facebook SDK functionality

- the module should successfully open the login screen when the login button is tapped
- the module should successfully open the share dialog when the share link is tapped

## Known Issues

- The App ID in use for the example is not configured, and it is problematic to configure one for the internet at large. Replace the App ID in `ios/RNFBSDKExample/Info.plist` and `android/src/main/res/values/strings.xml` with your App ID
- It does not demonstrate anything else, contributions welcome

## How to contribute to the example

- First, note that it is automatically constructed. The only file that is preserved when `refresh-example.sh` is run is `App.js`
- Make all UI changes in `App.js`
- Make all config changes (`Info.plist` or `.java` / `.m` file changes via sed edits in `refresh-example.sh`. No, that's not the easiest thing to do. But unless you commit to maintaining the project and updating the example app yourself for a few years, it is still the most efficient way)
14 changes: 14 additions & 0 deletions RNFBSDKExample/__tests__/App-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
3 changes: 3 additions & 0 deletions RNFBSDKExample/_editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files
[*.bat]
end_of_line = crlf
55 changes: 55 additions & 0 deletions RNFBSDKExample/android/app/_BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")

lib_deps = []

create_aar_targets(glob(["libs/*.aar"]))

create_jar_targets(glob(["libs/*.jar"]))

android_library(
name = "all-libs",
exported_deps = lib_deps,
)

android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)

android_build_config(
name = "build_config",
package = "com.rnfbsdkexample",
)

android_resource(
name = "res",
package = "com.rnfbsdkexample",
res = "src/main/res",
)

android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
Loading

0 comments on commit 1ec6d85

Please sign in to comment.