@react-native-firebase/app 23.8.0 → 23.8.2

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +1547 -0
  2. package/RNFBApp.podspec +49 -0
  3. package/android/.editorconfig +10 -0
  4. package/android/build.gradle +129 -0
  5. package/android/firebase-json.gradle +73 -0
  6. package/android/gradle.properties +2 -0
  7. package/android/lint.xml +5 -0
  8. package/android/settings.gradle +1 -0
  9. package/android/src/main/AndroidManifest.xml +24 -0
  10. package/android/src/main/java/io/invertase/firebase/app/.gitkeep +0 -0
  11. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +124 -0
  12. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +62 -0
  13. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +91 -0
  14. package/android/src/main/java/io/invertase/firebase/interfaces/.gitkeep +0 -0
  15. package/android/src/reactnative/AndroidManifest.xml +2 -0
  16. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +46 -0
  17. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppInitProvider.java +22 -0
  18. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppModule.java +186 -0
  19. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +49 -0
  20. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +35 -0
  21. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +22 -0
  22. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +191 -0
  23. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +53 -0
  24. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +151 -0
  25. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseInitProvider.java +78 -0
  26. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +107 -0
  27. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +93 -0
  28. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +146 -0
  29. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +88 -0
  30. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +440 -0
  31. package/android/src/reactnative/java/io/invertase/firebase/interfaces/ContextProvider.java +30 -0
  32. package/android/src/reactnative/java/io/invertase/firebase/interfaces/NativeError.java +32 -0
  33. package/android/src/reactnative/java/io/invertase/firebase/interfaces/NativeEvent.java +28 -0
  34. package/android/src/reactnative/java/io/invertase/firebase/utils/ReactNativeFirebaseUtilsModule.java +191 -0
  35. package/app.plugin.js +1 -0
  36. package/dist/commonjs/version.js +1 -1
  37. package/dist/module/version.js +1 -1
  38. package/dist/typescript/commonjs/lib/modular.d.ts +1 -1
  39. package/dist/typescript/commonjs/lib/version.d.ts +1 -1
  40. package/dist/typescript/module/lib/modular.d.ts +1 -1
  41. package/dist/typescript/module/lib/version.d.ts +1 -1
  42. package/firebase-schema.json +149 -0
  43. package/firebase_json.rb +72 -0
  44. package/ios/RNFBApp/RCTConvert+FIRApp.h +23 -0
  45. package/ios/RNFBApp/RCTConvert+FIRApp.m +31 -0
  46. package/ios/RNFBApp/RCTConvert+FIROptions.h +23 -0
  47. package/ios/RNFBApp/RCTConvert+FIROptions.m +36 -0
  48. package/ios/RNFBApp/RNFBAppModule.h +28 -0
  49. package/ios/RNFBApp/RNFBAppModule.m +305 -0
  50. package/ios/RNFBApp/RNFBJSON.h +36 -0
  51. package/ios/RNFBApp/RNFBJSON.m +99 -0
  52. package/ios/RNFBApp/RNFBMeta.h +30 -0
  53. package/ios/RNFBApp/RNFBMeta.m +61 -0
  54. package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +47 -0
  55. package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +74 -0
  56. package/ios/RNFBApp/RNFBPreferences.h +44 -0
  57. package/ios/RNFBApp/RNFBPreferences.m +94 -0
  58. package/ios/RNFBApp/RNFBRCTEventEmitter.h +73 -0
  59. package/ios/RNFBApp/RNFBRCTEventEmitter.m +151 -0
  60. package/ios/RNFBApp/RNFBSharedUtils.h +67 -0
  61. package/ios/RNFBApp/RNFBSharedUtils.m +285 -0
  62. package/ios/RNFBApp/RNFBUtilsModule.h +30 -0
  63. package/ios/RNFBApp/RNFBUtilsModule.m +100 -0
  64. package/ios/RNFBApp/RNFBVersion.h +20 -0
  65. package/ios/RNFBApp/RNFBVersion.m +21 -0
  66. package/ios/RNFBApp.xcodeproj/project.pbxproj +411 -0
  67. package/ios/RNFBApp.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
  68. package/ios_config.sh +269 -0
  69. package/lib/version.ts +1 -1
  70. package/package.json +4 -11
  71. package/plugin/build/android/applyPlugin.d.ts +6 -0
  72. package/plugin/build/android/applyPlugin.js +29 -0
  73. package/plugin/build/android/buildscriptDependency.d.ts +6 -0
  74. package/plugin/build/android/buildscriptDependency.js +31 -0
  75. package/plugin/build/android/constants.d.ts +4 -0
  76. package/plugin/build/android/constants.js +8 -0
  77. package/plugin/build/android/copyGoogleServices.d.ts +5 -0
  78. package/plugin/build/android/copyGoogleServices.js +33 -0
  79. package/plugin/build/android/index.d.ts +4 -0
  80. package/plugin/build/android/index.js +9 -0
  81. package/plugin/build/index.d.ts +3 -0
  82. package/plugin/build/index.js +21 -0
  83. package/plugin/build/ios/appDelegate.d.ts +6 -0
  84. package/plugin/build/ios/appDelegate.js +116 -0
  85. package/plugin/build/ios/googleServicesPlist.d.ts +7 -0
  86. package/plugin/build/ios/googleServicesPlist.js +42 -0
  87. package/plugin/build/ios/index.d.ts +3 -0
  88. package/plugin/build/ios/index.js +7 -0
  89. package/plugin/src/android/applyPlugin.ts +30 -0
  90. package/plugin/src/android/buildscriptDependency.ts +33 -0
  91. package/plugin/src/android/constants.ts +7 -0
  92. package/plugin/src/android/copyGoogleServices.ts +36 -0
  93. package/plugin/src/android/index.ts +5 -0
  94. package/plugin/src/index.ts +27 -0
  95. package/plugin/src/ios/appDelegate.ts +140 -0
  96. package/plugin/src/ios/googleServicesPlist.ts +55 -0
  97. package/plugin/src/ios/index.ts +4 -0
  98. package/plugin/tsconfig.json +9 -0
  99. package/plugin/tsconfig.tsbuildinfo +1 -0
  100. package/react-native.config.js +19 -0
  101. package/tsconfig.json +10 -0
@@ -0,0 +1,440 @@
1
+ package io.invertase.firebase.common;
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import android.annotation.SuppressLint;
21
+ import android.app.ActivityManager;
22
+ import android.content.Context;
23
+ import android.graphics.Point;
24
+ import android.graphics.Rect;
25
+ import android.net.Uri;
26
+ import android.os.Build;
27
+ import android.util.Log;
28
+ import com.facebook.react.bridge.*;
29
+ import com.facebook.react.common.LifecycleState;
30
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
31
+ import java.io.File;
32
+ import java.text.SimpleDateFormat;
33
+ import java.util.*;
34
+ import javax.annotation.Nullable;
35
+ import org.json.JSONArray;
36
+ import org.json.JSONException;
37
+ import org.json.JSONObject;
38
+
39
+ @SuppressWarnings({"unused", "JavaDoc", "WeakerAccess"})
40
+ public class SharedUtils {
41
+ private static final String TAG = "Utils";
42
+ private static final String RN_DEVSUPPORT_CLASS = "DevSupportManagerImpl";
43
+ private static final String RN_DEVSUPPORT_PACKAGE = "com.facebook.react.devsupport";
44
+
45
+ private static final String EXPO_REGISTRY_CLASS = "ModuleRegistry";
46
+ private static final String EXPO_CORE_PACKAGE = "expo.core";
47
+
48
+ private static final String FLUTTER_REGISTRY_CLASS = "PluginRegistry";
49
+ private static final String FLUTTER_CORE_PACKAGE = "io.flutter.plugin.common";
50
+
51
+ private static final String REACT_NATIVE_REGISTRY_CLASS = "NativeModuleRegistry";
52
+ private static final String REACT_NATIVE_CORE_PACKAGE = "com.facebook.react.bridge";
53
+
54
+ public static int[] rectToIntArray(@Nullable Rect rect) {
55
+ if (rect == null || rect.isEmpty()) return new int[] {};
56
+ return new int[] {rect.left, rect.top, rect.right, rect.bottom};
57
+ }
58
+
59
+ public static int[] pointToIntArray(@Nullable Point point) {
60
+ if (point == null) return new int[] {};
61
+ return new int[] {point.x, point.y};
62
+ }
63
+
64
+ public static List<int[]> pointsToIntsList(@Nullable Point[] points) {
65
+ if (points == null) return new ArrayList<>();
66
+
67
+ List<int[]> pointsList = new ArrayList<>(points.length);
68
+ for (Point point : points) {
69
+ pointsList.add(pointToIntArray(point));
70
+ }
71
+
72
+ return pointsList;
73
+ }
74
+
75
+ /** Create a Uri from the path, defaulting to file when there is no supplied scheme */
76
+ public static Uri getUri(String uri) {
77
+ Uri parsed = Uri.parse(uri);
78
+
79
+ if (parsed.getScheme() == null || parsed.getScheme().isEmpty()) {
80
+ return Uri.fromFile(new File(uri));
81
+ }
82
+
83
+ return parsed;
84
+ }
85
+
86
+ public static WritableMap getExceptionMap(Exception exception) {
87
+ WritableMap exceptionMap = Arguments.createMap();
88
+ String code = "unknown";
89
+ String message = exception.getMessage();
90
+ exceptionMap.putString("code", code);
91
+ exceptionMap.putString("nativeErrorCode", code);
92
+ exceptionMap.putString("message", message);
93
+ exceptionMap.putString("nativeErrorMessage", message);
94
+ return exceptionMap;
95
+ }
96
+
97
+ public static String timestampToUTC(long timestamp) {
98
+ long millisTimestamp = timestamp * 1000;
99
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ROOT);
100
+ format.setTimeZone(TimeZone.getTimeZone("UTC"));
101
+ return format.format(millisTimestamp);
102
+ }
103
+
104
+ /** send a JS event */
105
+ public static void sendEvent(final ReactContext context, final String eventName, Object body) {
106
+ if (context != null) {
107
+ context
108
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
109
+ .emit(eventName, body);
110
+ } else {
111
+ Log.d(TAG, "Missing context - cannot send event!");
112
+ }
113
+ }
114
+
115
+ /**
116
+ * We need to check if app is in foreground otherwise the app will crash.
117
+ * http://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not
118
+ *
119
+ * @param context Context
120
+ * @return boolean
121
+ */
122
+ public static boolean isAppInForeground(Context context) {
123
+ ActivityManager activityManager =
124
+ (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
125
+ if (activityManager == null) return false;
126
+
127
+ List<ActivityManager.RunningAppProcessInfo> appProcesses =
128
+ activityManager.getRunningAppProcesses();
129
+ if (appProcesses == null) return false;
130
+
131
+ // Check if current activity is a background activity
132
+ ReactNativeFirebaseJSON json = ReactNativeFirebaseJSON.getSharedInstance();
133
+ if (json.contains("android_background_activity_names")) {
134
+ ArrayList<String> backgroundActivities =
135
+ json.getArrayValue("android_background_activity_names");
136
+
137
+ if (backgroundActivities.size() != 0) {
138
+ String currentActivity = "";
139
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
140
+ List<ActivityManager.AppTask> taskInfo = activityManager.getAppTasks();
141
+ if (taskInfo.size() > 0) {
142
+ ActivityManager.RecentTaskInfo task = taskInfo.get(0).getTaskInfo();
143
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
144
+ currentActivity = task.baseActivity.getShortClassName();
145
+ } else {
146
+ currentActivity =
147
+ task.origActivity != null
148
+ ? task.origActivity.getShortClassName()
149
+ : task.baseIntent.getComponent().getShortClassName();
150
+ }
151
+ }
152
+ } else {
153
+ List<ActivityManager.RunningTaskInfo> taskInfo = activityManager.getRunningTasks(1);
154
+ if (taskInfo.size() > 0) {
155
+ currentActivity = taskInfo.get(0).topActivity.getShortClassName();
156
+ }
157
+ }
158
+
159
+ if (!"".equals(currentActivity) && backgroundActivities.contains(currentActivity)) {
160
+ return false;
161
+ }
162
+ }
163
+ }
164
+
165
+ final String packageName = context.getPackageName();
166
+ for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
167
+ if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
168
+ && appProcess.processName.equals(packageName)) {
169
+ ReactContext reactContext;
170
+
171
+ try {
172
+ reactContext = (ReactContext) context;
173
+ } catch (ClassCastException exception) {
174
+ // Not react context so default to true
175
+ return true;
176
+ }
177
+
178
+ return reactContext.getLifecycleState() == LifecycleState.RESUMED;
179
+ }
180
+ }
181
+
182
+ return false;
183
+ }
184
+
185
+ @SuppressLint("DiscouragedApi")
186
+ public static int getResId(Context ctx, String resName) {
187
+ int resourceId = ctx.getResources().getIdentifier(resName, "string", ctx.getPackageName());
188
+
189
+ if (resourceId == 0) {
190
+ Log.e(TAG, "resource " + resName + " could not be found");
191
+ }
192
+
193
+ return resourceId;
194
+ }
195
+
196
+ /**
197
+ * Checks for dev support availability - so we can ignore in release builds for example.
198
+ *
199
+ * @return Boolean
200
+ */
201
+ public static Boolean reactNativeHasDevSupport() {
202
+ return hasPackageClass(RN_DEVSUPPORT_PACKAGE, RN_DEVSUPPORT_CLASS);
203
+ }
204
+
205
+ /**
206
+ * Is the build platform Expo?
207
+ *
208
+ * @return Boolean
209
+ */
210
+ public static Boolean isExpo() {
211
+ return hasPackageClass(EXPO_CORE_PACKAGE, EXPO_REGISTRY_CLASS);
212
+ }
213
+
214
+ /**
215
+ * Is the build platform Flutter?
216
+ *
217
+ * @return Boolean
218
+ */
219
+ public static Boolean isFlutter() {
220
+ return hasPackageClass(FLUTTER_CORE_PACKAGE, FLUTTER_REGISTRY_CLASS);
221
+ }
222
+
223
+ /**
224
+ * Is the build platform React Native?
225
+ *
226
+ * @return Boolean
227
+ */
228
+ public static Boolean isReactNative() {
229
+ return !isExpo() && hasPackageClass(REACT_NATIVE_CORE_PACKAGE, REACT_NATIVE_REGISTRY_CLASS);
230
+ }
231
+
232
+ /**
233
+ * Returns true/false if a class for a package exists in the app class bundle
234
+ *
235
+ * @param packageName
236
+ * @param className
237
+ * @return
238
+ */
239
+ @SuppressWarnings("StringBufferReplaceableByString")
240
+ public static Boolean hasPackageClass(String packageName, String className) {
241
+ // ProGuard is surprisingly smart in this case and will keep a class if it detects a call to
242
+ // Class.forName() with a static string. So instead we generate a quasi-dynamic string to
243
+ // confuse it.
244
+ String fullName = new StringBuilder(packageName).append(".").append(className).toString();
245
+
246
+ try {
247
+ Class.forName(fullName);
248
+ return true;
249
+ } catch (Exception e) {
250
+ return false;
251
+ }
252
+ }
253
+
254
+ public static WritableMap jsonObjectToWritableMap(JSONObject jsonObject) throws JSONException {
255
+ Iterator<String> iterator = jsonObject.keys();
256
+ WritableMap writableMap = Arguments.createMap();
257
+
258
+ while (iterator.hasNext()) {
259
+ String key = iterator.next();
260
+ Object value = jsonObject.get(key);
261
+ if (value instanceof Float || value instanceof Double) {
262
+ writableMap.putDouble(key, jsonObject.getDouble(key));
263
+ } else if (value instanceof Number) {
264
+ writableMap.putInt(key, jsonObject.getInt(key));
265
+ } else if (value instanceof String) {
266
+ writableMap.putString(key, jsonObject.getString(key));
267
+ } else if (value instanceof JSONObject) {
268
+ writableMap.putMap(key, jsonObjectToWritableMap(jsonObject.getJSONObject(key)));
269
+ } else if (value instanceof JSONArray) {
270
+ writableMap.putArray(key, jsonArrayToWritableArray(jsonObject.getJSONArray(key)));
271
+ } else if (value == JSONObject.NULL) {
272
+ writableMap.putNull(key);
273
+ }
274
+ }
275
+
276
+ return writableMap;
277
+ }
278
+
279
+ public static WritableArray jsonArrayToWritableArray(JSONArray jsonArray) throws JSONException {
280
+ WritableArray writableArray = Arguments.createArray();
281
+
282
+ for (int i = 0; i < jsonArray.length(); i++) {
283
+ Object value = jsonArray.get(i);
284
+ if (value instanceof Float || value instanceof Double) {
285
+ writableArray.pushDouble(jsonArray.getDouble(i));
286
+ } else if (value instanceof Number) {
287
+ writableArray.pushInt(jsonArray.getInt(i));
288
+ } else if (value instanceof String) {
289
+ writableArray.pushString(jsonArray.getString(i));
290
+ } else if (value instanceof JSONObject) {
291
+ writableArray.pushMap(jsonObjectToWritableMap(jsonArray.getJSONObject(i)));
292
+ } else if (value instanceof JSONArray) {
293
+ writableArray.pushArray(jsonArrayToWritableArray(jsonArray.getJSONArray(i)));
294
+ } else if (value == JSONObject.NULL) {
295
+ writableArray.pushNull();
296
+ }
297
+ }
298
+ return writableArray;
299
+ }
300
+
301
+ public static WritableMap mapToWritableMap(Map<String, Object> value) {
302
+ WritableMap writableMap = Arguments.createMap();
303
+
304
+ for (Map.Entry<String, Object> entry : value.entrySet()) {
305
+ mapPutValue(entry.getKey(), entry.getValue(), writableMap);
306
+ }
307
+
308
+ return writableMap;
309
+ }
310
+
311
+ private static WritableArray listToWritableArray(List<Object> objects) {
312
+ WritableArray writableArray = Arguments.createArray();
313
+ for (Object object : objects) {
314
+ arrayPushValue(object, writableArray);
315
+ }
316
+ return writableArray;
317
+ }
318
+
319
+ @SuppressWarnings("unchecked")
320
+ public static void arrayPushValue(@Nullable Object value, WritableArray array) {
321
+ if (value == null || value == JSONObject.NULL) {
322
+ array.pushNull();
323
+ return;
324
+ }
325
+
326
+ String type = value.getClass().getName();
327
+ switch (type) {
328
+ case "java.lang.Boolean":
329
+ array.pushBoolean((Boolean) value);
330
+ break;
331
+ case "java.lang.Long":
332
+ Long longVal = (Long) value;
333
+ array.pushDouble((double) longVal);
334
+ break;
335
+ case "java.lang.Float":
336
+ float floatVal = (float) value;
337
+ array.pushDouble((double) floatVal);
338
+ break;
339
+ case "java.lang.Double":
340
+ array.pushDouble((double) value);
341
+ break;
342
+ case "java.lang.Integer":
343
+ array.pushInt((int) value);
344
+ break;
345
+ case "java.lang.String":
346
+ array.pushString((String) value);
347
+ break;
348
+ case "org.json.JSONObject$1":
349
+ try {
350
+ array.pushMap(jsonObjectToWritableMap((JSONObject) value));
351
+ } catch (JSONException e) {
352
+ array.pushNull();
353
+ }
354
+ break;
355
+ case "org.json.JSONArray$1":
356
+ try {
357
+ array.pushArray(jsonArrayToWritableArray((JSONArray) value));
358
+ } catch (JSONException e) {
359
+ array.pushNull();
360
+ }
361
+ break;
362
+ default:
363
+ if (List.class.isAssignableFrom(value.getClass())) {
364
+ array.pushArray(listToWritableArray((List<Object>) value));
365
+ } else if (Map.class.isAssignableFrom(value.getClass())) {
366
+ array.pushMap(mapToWritableMap((Map<String, Object>) value));
367
+ } else {
368
+ Log.d(TAG, "utils:arrayPushValue:unknownType:" + type);
369
+ array.pushNull();
370
+ }
371
+ }
372
+ }
373
+
374
+ @SuppressWarnings("unchecked")
375
+ public static void mapPutValue(String key, @Nullable Object value, WritableMap map) {
376
+ if (value == null || value == JSONObject.NULL) {
377
+ map.putNull(key);
378
+ return;
379
+ }
380
+
381
+ String type = value.getClass().getName();
382
+ switch (type) {
383
+ case "java.lang.Boolean":
384
+ map.putBoolean(key, (Boolean) value);
385
+ break;
386
+ case "java.lang.Long":
387
+ Long longVal = (Long) value;
388
+ map.putDouble(key, (double) longVal);
389
+ break;
390
+ case "java.lang.Float":
391
+ float floatVal = (float) value;
392
+ map.putDouble(key, (double) floatVal);
393
+ break;
394
+ case "java.lang.Double":
395
+ map.putDouble(key, (double) value);
396
+ break;
397
+ case "java.lang.Integer":
398
+ map.putInt(key, (int) value);
399
+ break;
400
+ case "java.lang.String":
401
+ map.putString(key, (String) value);
402
+ break;
403
+ case "org.json.JSONObject$1":
404
+ try {
405
+ map.putMap(key, jsonObjectToWritableMap((JSONObject) value));
406
+ } catch (JSONException e) {
407
+ map.putNull(key);
408
+ }
409
+ break;
410
+ case "org.json.JSONArray$1":
411
+ try {
412
+ map.putArray(key, jsonArrayToWritableArray((JSONArray) value));
413
+ } catch (JSONException e) {
414
+ map.putNull(key);
415
+ }
416
+ break;
417
+ default:
418
+ if (List.class.isAssignableFrom(value.getClass())) {
419
+ map.putArray(key, listToWritableArray((List<Object>) value));
420
+ } else if (Map.class.isAssignableFrom(value.getClass())) {
421
+ map.putMap(key, mapToWritableMap((Map<String, Object>) value));
422
+ } else {
423
+ Log.d(TAG, "utils:mapPutValue:unknownType:" + type);
424
+ map.putNull(key);
425
+ }
426
+ }
427
+ }
428
+
429
+ /**
430
+ * Convert a ReadableMap to a WritableMap for the purposes of re-sending back to JS
431
+ *
432
+ * @param map ReadableMap
433
+ * @return WritableMap
434
+ */
435
+ public static WritableMap readableMapToWritableMap(ReadableMap map) {
436
+ WritableMap writableMap = Arguments.createMap();
437
+ writableMap.merge(map);
438
+ return writableMap;
439
+ }
440
+ }
@@ -0,0 +1,30 @@
1
+ package io.invertase.firebase.interfaces;
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import android.app.Activity;
21
+ import android.content.Context;
22
+ import com.facebook.react.bridge.ReactContext;
23
+
24
+ public interface ContextProvider {
25
+ Activity getActivity();
26
+
27
+ ReactContext getContext();
28
+
29
+ Context getApplicationContext();
30
+ }
@@ -0,0 +1,32 @@
1
+ package io.invertase.firebase.interfaces;
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import com.facebook.react.bridge.WritableMap;
21
+
22
+ public interface NativeError {
23
+ String getErrorCode();
24
+
25
+ String getErrorMessage();
26
+
27
+ String getFirebaseAppName();
28
+
29
+ String getFirebaseServiceName();
30
+
31
+ WritableMap getUserInfo();
32
+ }
@@ -0,0 +1,28 @@
1
+ package io.invertase.firebase.interfaces;
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import com.facebook.react.bridge.WritableMap;
21
+
22
+ public interface NativeEvent {
23
+ String getEventName();
24
+
25
+ WritableMap getEventBody();
26
+
27
+ String getFirebaseAppName();
28
+ }