Skip to content

Instantly share code, notes, and snippets.

View asumansenol's full-sized avatar

Asuman Şenol asumansenol

View GitHub Profile
import React from "react";
import {
StyleSheet,
View,
Text,
TextInput,
SafeAreaView,
TouchableOpacity,
KeyboardAvoidingView,
ActivityIndicator,
import React from "react";
import {
StyleSheet,
View,
Text,
TextInput,
SafeAreaView,
TouchableOpacity,
KeyboardAvoidingView,
ActivityIndicator,
import { createSwitchNavigator } from 'react-navigation';
import LoadingScreen from '../screens/LoadingScreen';
import SignUpScreen from '../screens/SignUpScreen';
import SignInScreen from '../screens/SignInScreen';
const AuthNavigator = createSwitchNavigator(
{
Loading: { screen: LoadingScreen },
SignUp: { screen: SignUpScreen },
SignIn: { screen: SignInScreen }
},
import { createAppContainer, createSwitchNavigator } from 'react-navigation';
import firebase from 'firebase';
import { firebaseConfig } from './config/firebase.js';
import AuthNavigator from './navigation/AuthNavigator';
import HomeScreen from './screens/HomeScreen.js';
import * as Segment from 'expo-analytics-segment';
firebase.initializeApp(firebaseConfig);
Segment.initialize({ androidWriteKey:"aWa3QRFL2QD3VL2oE2yAfvutRE2mBUGm", iosWriteKey:"aWa3QRFL2QD3VL2oE2yAfvutRE2mBUGm" })
import React from 'react';
import { View, StyleSheet, ActivityIndicator } from 'react-native';
import firebase from 'firebase';
class LoadingScreen extends React.Component {
componentDidMount() {
firebase.auth().onAuthStateChanged(user => {
if (user) {
this.props.navigation.navigate('App');
} else {
this.props.navigation.navigate('SignUp');
import React from 'react';
import { StyleSheet, Text, View, SafeAreaView, Button } from 'react-native';
import firebase from 'firebase';
class HomeScreen extends React.Component {
state = { user: {} };
componentDidMount() {
firebase.auth().onAuthStateChanged((user) => {
if (user != null) {
signInWithGoogleAsync = async () => {
try {
const result = await Google.logInAsync({
androidClientId: ANDRIOID_CLIENT_ID,
iosClientId: IOS_CLIENT_ID,
behavior: 'web',
iosClientId: '', //enter ios client id
scopes: ['profile', 'email']
});
async signInWithGoogle() {
try {
const result = await Expo.Google.logInAsync({
androidClientId: ANDROID_CLIENT_ID,
iosClientId: IOS_CLIENT_ID,
behavior: 'web',
iosClientId: '', //enter ios client id
scopes: ['profile', 'email']
});
export const firebaseConfig = {
apiKey: "WRITE YOUR API KEY",
authDomain: "WRITE YOUR AUTH DOMAIN",
databaseURL: "WRITE YOUR DATABASE URL",
projectId: "WRITE YOUR PROJ ID",
storageBucket: "WRITE YOUR STORAGE BUCKET",
messagingSenderId: "WRITE YOUR MESSAGING SENDER ID",
appId: "WRITE YOUR APP ID",
measurementId: "WRITE YOUR MEASUREMENT ID"
};
async signInWithFacebook() {
try {
const { type, token } = await Facebook.logInWithReadPermissionsAsync('Enter your Facebook App Id', {
permissions: ['public_profile'],
});
if (type === 'success') {
await firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
const credential = firebase.auth.FacebookAuthProvider.credential(token);
const facebookProfileData = await firebase.auth().signInWithCredential(credential);
this.onLoginSuccess.bind(this)