mayo-firebase-config 1.2.11 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
|
|
1
1
|
package com.mayofirebaseconfig;
|
2
2
|
|
3
|
+
import android.util.Log;
|
4
|
+
|
3
5
|
import com.facebook.react.bridge.ReactApplicationContext;
|
4
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
5
7
|
import com.facebook.react.bridge.ReactMethod;
|
@@ -32,14 +34,20 @@ public class FirebaseConfigExtractorModule extends ReactContextBaseJavaModule {
|
|
32
34
|
|
33
35
|
@ReactMethod
|
34
36
|
public void extractConfig(Promise promise) {
|
37
|
+
Log.d(NAME, "Starting to extract Firebase config.");
|
35
38
|
try {
|
36
39
|
// Use AssetManager to read the google-services.json file from the assets folder
|
37
40
|
AssetManager assetManager = getReactApplicationContext().getAssets();
|
41
|
+
Log.d(NAME, "Attempting to open google-services.json file.");
|
38
42
|
InputStream input = assetManager.open("google-services.json");
|
39
|
-
|
43
|
+
Log.d(NAME, "google-services.json file opened successfully.");
|
44
|
+
|
40
45
|
// Convert InputStream to String
|
41
46
|
String json = convertStreamToString(input);
|
42
47
|
|
48
|
+
// Log raw JSON string
|
49
|
+
Log.d(NAME, "JSON string: " + json);
|
50
|
+
|
43
51
|
// Use JSONObject to parse the JSON string
|
44
52
|
JSONObject jsonObject = new JSONObject(json);
|
45
53
|
JSONArray clientArray = jsonObject.getJSONArray("client");
|
@@ -48,6 +56,10 @@ public class FirebaseConfigExtractorModule extends ReactContextBaseJavaModule {
|
|
48
56
|
JSONArray apiKeyArray = clientObject.getJSONArray("api_key");
|
49
57
|
JSONObject apiKeyObject = apiKeyArray.getJSONObject(0);
|
50
58
|
|
59
|
+
// Log parsed objects
|
60
|
+
Log.d(NAME, "Parsed projectInfo: " + projectInfo.toString());
|
61
|
+
Log.d(NAME, "Parsed apiKeyObject: " + apiKeyObject.toString());
|
62
|
+
|
51
63
|
// Extract webClientId
|
52
64
|
JSONArray oauthClientArray = clientObject.getJSONArray("oauth_client");
|
53
65
|
String webClientId = "";
|
@@ -72,7 +84,11 @@ public class FirebaseConfigExtractorModule extends ReactContextBaseJavaModule {
|
|
72
84
|
config.put("databaseURL", "https://" + projectInfo.getString("project_id") + ".firebaseio.com");
|
73
85
|
|
74
86
|
promise.resolve(config);
|
87
|
+
} catch (IOException e) {
|
88
|
+
Log.e(NAME, "Error reading Firebase config file", e);
|
89
|
+
promise.reject("ERR_IO_EXCEPTION", "Error reading Firebase config file", e);
|
75
90
|
} catch (Exception e) {
|
91
|
+
Log.e(NAME, "Error extracting Firebase config on Android", e);
|
76
92
|
promise.reject("ERR_UNEXPECTED_EXCEPTION", "Error extracting Firebase config on Android", e);
|
77
93
|
}
|
78
94
|
}
|