mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-15 23:04:07 +08:00
68 lines
2.2 KiB
JavaScript
68 lines
2.2 KiB
JavaScript
/**
|
|
* Sample React Native App with Firebase
|
|
* https://github.com/invertase/react-native-firebase
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
import React, { Component } from 'react';
|
|
import { Platform, StyleSheet, Text, View } from 'react-native';
|
|
|
|
import firebase from '@react-native-firebase/app';
|
|
|
|
// TODO(you): import any additional firebase services that you require for your app, e.g for auth:
|
|
// 1) install the npm package: `yarn add @react-native-firebase/auth@alpha` - you do not need to
|
|
// run linking commands - this happens automatically at build time now
|
|
// 2) rebuild your app via `yarn run run:android` or `yarn run run:ios`
|
|
// 3) import the package here in your JavaScript code: `import '@react-native-firebase/auth';`
|
|
// 4) The Firebase Auth service is now available to use here: `firebase.auth().currentUser`
|
|
|
|
const instructions = Platform.select({
|
|
ios: 'Press Cmd+R to reload,\nCmd+D or shake for dev menu',
|
|
android: 'Double tap R on your keyboard to reload,\nShake or press menu button for dev menu',
|
|
});
|
|
|
|
const firebaseCredentials = Platform.select({
|
|
ios: 'https://invertase.link/firebase-ios',
|
|
android: 'https://invertase.link/firebase-android',
|
|
});
|
|
|
|
type Props = {};
|
|
|
|
export default class App extends Component<Props> {
|
|
render() {
|
|
return (
|
|
<View style={styles.container}>
|
|
<Text style={styles.welcome}>Welcome to React Native + Firebase!</Text>
|
|
<Text style={styles.instructions}>To get started, edit App.js</Text>
|
|
<Text style={styles.instructions}>{instructions}</Text>
|
|
{!firebase.apps.length && (
|
|
<Text style={styles.instructions}>
|
|
{`\nYou currently have no Firebase apps registered, this most likely means you've not downloaded your project credentials. Visit the link below to learn more. \n\n ${firebaseCredentials}`}
|
|
</Text>
|
|
)}
|
|
</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,
|
|
},
|
|
});
|