|
1 | 1 | # react-native-quick-firebase |
2 | 2 |
|
3 | | - |
4 | | - |
| 3 | + |
| 4 | + |
5 | 5 |
|
6 | 6 | Firebase simple integration with phone auth and analytics only. |
7 | 7 |
|
8 | 8 | Implementation in React Native project |
9 | 9 |
|
10 | 10 | Please add this entries as follow - |
11 | 11 |
|
12 | | -- _iOS_ ( In Podfile) |
| 12 | +- _iOS_ ( In Podfile) |
13 | 13 |
|
14 | 14 | ``` |
15 | 15 | pod 'RNQuickFirebase', :path => PROJECT_PATH + 'react-native-quick-firebase/ios' |
16 | 16 | pod 'Firebase/Auth' |
17 | 17 | pod 'FirebaseAnalytics' |
18 | 18 | ``` |
19 | 19 |
|
20 | | -- _Android_ |
| 20 | +- _Android_ |
21 | 21 |
|
22 | 22 | android/settings.gradle |
23 | 23 |
|
@@ -59,50 +59,50 @@ public class MainApplication extends Application implements ReactApplication { |
59 | 59 | // Copyright © 2017-Present, Gaurav D. Sharma |
60 | 60 | // All rights reserved. |
61 | 61 | // |
62 | | -'use strict'; |
| 62 | +'use strict' |
63 | 63 |
|
64 | | -import React, { Component } from 'react'; |
65 | | -import { AppRegistry, Text, TouchableOpacity, View } from 'react-native'; |
66 | | -import RNQuickFirebase from 'react-native-quick-firebase'; |
| 64 | +import React, { Component } from 'react' |
| 65 | +import { AppRegistry, Text, TouchableOpacity, View } from 'react-native' |
| 66 | +import RNQuickFirebase from 'react-native-quick-firebase' |
67 | 67 |
|
68 | 68 | class App extends Component { |
69 | | - componentDidMount() { |
70 | | - RNQuickFirebase.setAnalyticsEnabled(true); |
71 | | - } |
72 | | - |
73 | | - onSendOTP = async () => { |
74 | | - RNQuickFirebase.logEvent('otp_button_click', null); |
75 | | - let params = null; |
76 | | - try { |
77 | | - const phoneNumber = '+919876543210'; |
78 | | - await RNQuickFirebase.sendOTP(phoneNumber); |
79 | | - console.warn('otp sent to: ' + phoneNumber); |
80 | | - const sessionToken = await RNQuickFirebase.validateOTP('123456'); |
81 | | - console.warn('OTP validated successfully with sessionToken: ' + sessionToken); |
82 | | - params = { otp_validate_event: 'otp_success' }; |
83 | | - RNQuickFirebase.logEvent('otp_send_validate', params); |
84 | | - /// send this token to server to cross validate |
85 | | - RNQuickFirebase.signOut(); |
86 | | - console.warn('User Logout from the Firebase'); |
87 | | - } catch (e) { |
88 | | - console.warn(e); |
89 | | - params = { ['otp_send_event']: 'otp_failed' }; |
90 | | - RNQuickFirebase.logEvent('otp_send_validate', null); |
91 | | - } |
92 | | - }; |
93 | | - |
94 | | - render() { |
95 | | - return ( |
96 | | - <View style={{ flex: 1, backgroundColor: 'white', justifyContent: 'center', alignItems: 'center' }}> |
97 | | - <TouchableOpacity onPress={this.onSendOTP}> |
98 | | - <Text>Check RNQuickFirebase App</Text> |
99 | | - </TouchableOpacity> |
100 | | - </View> |
101 | | - ); |
102 | | - } |
| 69 | + componentDidMount() { |
| 70 | + RNQuickFirebase.setAnalyticsEnabled(true) |
| 71 | + } |
| 72 | + |
| 73 | + onSendOTP = async () => { |
| 74 | + RNQuickFirebase.logEvent('otp_button_click', null) |
| 75 | + let params = null |
| 76 | + try { |
| 77 | + const phoneNumber = '+919876543210' |
| 78 | + await RNQuickFirebase.sendOTP(phoneNumber) |
| 79 | + console.warn('otp sent to: ' + phoneNumber) |
| 80 | + const sessionToken = await RNQuickFirebase.validateOTP('123456') |
| 81 | + console.warn('OTP validated successfully with sessionToken: ' + sessionToken) |
| 82 | + params = { otp_validate_event: 'otp_success' } |
| 83 | + RNQuickFirebase.logEvent('otp_send_validate', params) |
| 84 | + /// send this token to server to cross validate |
| 85 | + RNQuickFirebase.signOut() |
| 86 | + console.warn('User Logout from the Firebase') |
| 87 | + } catch (e) { |
| 88 | + console.warn(e) |
| 89 | + params = { ['otp_send_event']: 'otp_failed' } |
| 90 | + RNQuickFirebase.logEvent('otp_send_validate', null) |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + render() { |
| 95 | + return ( |
| 96 | + <View style={{ flex: 1, backgroundColor: 'white', justifyContent: 'center', alignItems: 'center' }}> |
| 97 | + <TouchableOpacity onPress={this.onSendOTP}> |
| 98 | + <Text>Check RNQuickFirebase App</Text> |
| 99 | + </TouchableOpacity> |
| 100 | + </View> |
| 101 | + ) |
| 102 | + } |
103 | 103 | } |
104 | 104 |
|
105 | | -AppRegistry.registerComponent('firebaseDemo', () => App); |
| 105 | +AppRegistry.registerComponent('firebaseDemo', () => App) |
106 | 106 | ``` |
107 | 107 |
|
108 | 108 | Voila! Happy Coding! 😍 |
0 commit comments