-
Notifications
You must be signed in to change notification settings - Fork 59
/
Code.txt
162 lines (132 loc) · 4.46 KB
/
Code.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
react-native init RN-firechat
cd RN-firechat
npm install
Package:
https://reactnavigation.org/docs/intro/
https://github.com/joinspontaneous/react-native-loading-spinner-overlay
https://github.com/invertase/react-native-firebase/
https://github.com/FaridSafi/react-native-gifted-chat
npm install --save react-navigation
npm install --save react-native-loading-spinner-overlay@latest
npm install --save react-native-firebase
npm install react-native-gifted-chat --save
react-native link
react-native link react-native-firebase
Usage:
import { StackNavigator } from "react-navigation";
and
return (
<View>
<Boiler navigation={this.props.navigation} />
</View>
);
and
const app = StackNavigator({
Boiler: {
screen: HomeScreen,
navigationOptions: {
title: "Boiler"
}
}
});
Usage spinner:
import Spinner from "react-native-loading-spinner-overlay";
this.state = {
loading: false
};
<Spinner visible={this.state.loading} />
when need to show spinner: this.setState({ loading: true });
when need to hide spinner: this.setState({ loading: false });
Usage Firebase:
place this file in the root of your project at android/app/google-services.json
in android/build.gradle:
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// -------------------------------------------------
// Add this below the existing maven property above
// -------------------------------------------------
maven {
url 'https://maven.google.com'
}
}
}
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.1.1'
}
}
in android/app/build.gradle :
dependencies {
// This should be here already
compile(project(':react-native-firebase')) {
transitive = false
}
// Firebase dependencies
compile "com.google.android.gms:play-services-base:11.4.2"
compile "com.google.firebase:firebase-core:11.4.2"
compile "com.google.firebase:firebase-auth:11.4.2"
compile "com.google.firebase:firebase-database:11.4.2"
compile "com.google.firebase:firebase-messaging:11.4.2"
add in bottom:
apply plugin: 'com.google.gms.google-services'
In android/app/src/main/java/com/[app name]/MainApplication.java:
// ...
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
public class MainApplication extends Application implements ReactApplication {
// ...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNFirebasePackage(),
new RNFirebaseAuthPackage(),
new RNFirebaseDatabasePackage(),
new RNFirebaseMessagingPackage()
);
}
};
// ...
}
android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<activity
...
android:launchMode="singleTop"
>
<application ...>
<service
android:name="io.invertase.firebase.messaging.MessagingService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<receiver android:name="io.invertase.firebase.messaging.RNFirebaseLocalMessagingPublisher"/>
<receiver android:enabled="true" android:exported="true" android:name="io.invertase.firebase.messaging.RNFirebaseSystemBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Generating Signed APK :
https://facebook.github.io/react-native/docs/signed-apk-android.html