@@ -33,6 +33,7 @@ class FirestackModule extends ReactContextBaseJavaModule {
33
33
private static final String TAG = "FirestackModule" ;
34
34
private Context context ;
35
35
private FirebaseAuth mAuth ;
36
+ private FirebaseApp app ;
36
37
private FirebaseUser user ;
37
38
private FirebaseAuth .AuthStateListener mAuthListener ;
38
39
@@ -49,7 +50,7 @@ public String getName() {
49
50
50
51
@ ReactMethod
51
52
public void configureWithOptions (ReadableMap params , @ Nullable final Callback onComplete ) {
52
- Log .d (TAG , "configureWithOptions" );
53
+ Log .i (TAG , "configureWithOptions" );
53
54
54
55
ReactContext mCtx = getReactApplicationContext ();
55
56
FirebaseOptions .Builder builder = new FirebaseOptions .Builder ();
@@ -66,35 +67,45 @@ public void configureWithOptions(ReadableMap params, @Nullable final Callback on
66
67
}
67
68
if (params .hasKey ("gcmSenderID" )) {
68
69
final String gcmSenderID = params .getString ("gcmSenderID" );
69
- Log .d (TAG , "Setting gcmSenderID from params" + gcmSenderID );
70
+ Log .d (TAG , "Setting gcmSenderID from params " + gcmSenderID );
70
71
builder .setGcmSenderId (gcmSenderID );
71
72
}
72
73
if (params .hasKey ("storageBucket" )) {
73
74
final String storageBucket = params .getString ("storageBucket" );
74
- Log .d (TAG , "Setting storageBucket from params" + storageBucket );
75
+ Log .d (TAG , "Setting storageBucket from params " + storageBucket );
75
76
builder .setStorageBucket (storageBucket );
76
77
}
77
78
if (params .hasKey ("databaseURL" )) {
78
79
final String databaseURL = params .getString ("databaseURL" );
79
- Log .d (TAG , "Setting databaseURL from params" + databaseURL );
80
+ Log .d (TAG , "Setting databaseURL from params " + databaseURL );
80
81
builder .setDatabaseUrl (databaseURL );
81
82
}
82
83
if (params .hasKey ("clientID" )) {
83
84
final String clientID = params .getString ("clientID" );
84
- Log .d (TAG , "Setting clientID from params" + clientID );
85
+ Log .d (TAG , "Setting clientID from params " + clientID );
85
86
builder .setApplicationId (clientID );
86
87
}
87
88
88
89
try {
89
- Log .i (TAG , "Configuring" );
90
- FirebaseApp app = FirebaseApp .initializeApp (mCtx , builder .build ());
90
+ Log .i (TAG , "Configuring app" );
91
+ if (app == null ) {
92
+ app = FirebaseApp .initializeApp (mCtx , builder .build ());
93
+ }
91
94
Log .i (TAG , "Configured" );
92
- onComplete .invoke (app );
95
+ System .out .println ("Configured" );
96
+
97
+ WritableMap resp = Arguments .createMap ();
98
+ resp .putString ("msg" , "success" );
99
+ onComplete .invoke (null , resp );
93
100
}
94
101
catch (Exception ex ){
95
102
Log .e (TAG , "ERROR configureWithOptions" );
96
103
Log .e (TAG , ex .getMessage ());
97
- onComplete .invoke (ex .getMessage ());
104
+
105
+ WritableMap resp = Arguments .createMap ();
106
+ resp .putString ("msg" , ex .getMessage ());
107
+
108
+ onComplete .invoke (resp );
98
109
}
99
110
}
100
111
0 commit comments