12
12
import com .facebook .react .bridge .ReactMethod ;
13
13
import com .facebook .react .bridge .Callback ;
14
14
import com .facebook .react .bridge .WritableMap ;
15
+ import com .facebook .react .bridge .ReadableMap ;
15
16
import com .facebook .react .modules .core .DeviceEventManagerModule ;
16
17
import com .facebook .react .bridge .ReactContext ;
17
18
18
19
import com .google .android .gms .tasks .OnCompleteListener ;
19
20
import com .google .android .gms .tasks .OnFailureListener ;
20
21
import com .google .android .gms .tasks .Task ;
22
+ import com .google .firebase .FirebaseApp ;
23
+ import com .google .firebase .FirebaseOptions ;
24
+
21
25
import com .google .firebase .auth .AuthCredential ;
22
26
import com .google .firebase .auth .AuthResult ;
23
27
import com .google .firebase .auth .FacebookAuthProvider ;
@@ -42,6 +46,37 @@ public String getName() {
42
46
return "Firestack" ;
43
47
}
44
48
49
+ @ ReactMethod
50
+ public void configureWithOptions (ReadableMap params , final Callback onSuccess ) {
51
+ ReactContext mCtx = getReactApplicationContext ();
52
+ FirebaseOptions .Builder builder = new FirebaseOptions .Builder ();
53
+
54
+ if (params .hasKey ("apiKey" )) {
55
+ builder .setApiKey (params .getString ("apiKey" ));
56
+ }
57
+ if (params .hasKey ("gcmSenderID" )) {
58
+ builder .setGcmSenderId (params .getString ("gcmSenderID" ));
59
+ }
60
+ if (params .hasKey ("storageBucket" )) {
61
+ builder .setStorageBucket (params .getString ("storageBucket" ));
62
+ }
63
+ if (params .hasKey ("databaseURL" )) {
64
+ builder .setDatabaseUrl (params .getString ("databaseURL" ));
65
+ }
66
+ if (params .hasKey ("clientID" )) {
67
+ builder .setApplicationId (params .getString ("clientID" ));
68
+ }
69
+
70
+ try {
71
+ FirebaseApp app = FirebaseApp .initializeApp (mCtx , builder .build ());
72
+ }
73
+ catch (Exception e ){
74
+
75
+ }
76
+
77
+ onSuccess .invoke ();
78
+ }
79
+
45
80
@ ReactMethod
46
81
public void listenForAuth () {
47
82
mAuthListener = new FirebaseAuth .AuthStateListener () {
0 commit comments