Skip to content

Instantly share code, notes, and snippets.

@radinreth
Created December 29, 2018 05:34
Show Gist options
  • Save radinreth/8982a2c24cecb36b3e047c869f4ff9a3 to your computer and use it in GitHub Desktop.
Save radinreth/8982a2c24cecb36b3e047c869f4ff9a3 to your computer and use it in GitHub Desktop.

Revisions

  1. radinreth created this gist Dec 29, 2018.
    55 changes: 55 additions & 0 deletions App.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    import React, {Component} from 'react';
    import {Platform, StyleSheet, Text, View} from 'react-native';
    import { LoginButton, AccessToken } from 'react-native-fbsdk';

    const instructions = Platform.select({
    ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
    android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
    });

    export default class App extends Component {
    render() {
    return (
    <View style={styles.container}>
    <LoginButton
    onLoginFinished={
    (error, result) => {
    if (error) {
    console.log("login has error: " + result.error);
    } else if (result.isCancelled) {
    console.log("login is cancelled.");
    } else {
    AccessToken.getCurrentAccessToken().then(
    (data) => {
    console.log(data.accessToken.toString())
    }
    )
    }
    }
    }
    onLogoutFinished={() => console.log("logout.")}/>
    </View>
    );
    }
    }

    const styles = StyleSheet.create({
    container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
    },
    welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
    },
    instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
    },
    });