@react-native-firebase/app 26.4.0 → 27.1.0

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 (242) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +10 -27
  3. package/RNFBApp.podspec +13 -5
  4. package/android/build.gradle +3 -0
  5. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.kt +29 -0
  6. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.kt +146 -0
  7. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.kt +156 -0
  8. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.kt +44 -0
  9. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.kt +100 -0
  10. package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.kt +250 -0
  11. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.kt +64 -0
  12. package/android/src/reactnative/java/io/invertase/firebase/app/{ReactNativeFirebaseAppInitProvider.java → ReactNativeFirebaseAppInitProvider.kt} +3 -4
  13. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.kt +47 -0
  14. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.kt +33 -0
  15. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
  16. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.kt +185 -0
  17. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.kt +35 -0
  18. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.kt +662 -0
  19. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.kt +103 -0
  20. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.kt +96 -0
  21. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.kt +140 -0
  22. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.kt +109 -0
  23. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.kt +451 -0
  24. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{ContextProvider.java → ContextProvider.kt} +8 -8
  25. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeError.java → NativeError.kt} +8 -8
  26. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeEvent.java → NativeEvent.kt} +6 -6
  27. package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.kt +219 -0
  28. package/android/src/test/java/expo/core/ModuleRegistry.java +9 -0
  29. package/android/src/test/java/io/invertase/firebase/app/NativeRNFBTurboAppTest.java +182 -59
  30. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppComponentsJavaCompatibilityTest.java +70 -0
  31. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppJavaCompatibilityTest.java +60 -0
  32. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackageTest.java +165 -0
  33. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppTest.kt +167 -0
  34. package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseJavaCompatibilityTest.java +112 -0
  35. package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseTest.kt +317 -0
  36. package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.kt +309 -0
  37. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterJavaCompatibilityTest.java +176 -0
  38. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterTest.java +143 -12
  39. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventTest.kt +61 -0
  40. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONJavaCompatibilityTest.java +85 -0
  41. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.kt +296 -0
  42. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaJavaCompatibilityTest.java +67 -0
  43. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaTest.kt +246 -0
  44. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseModuleTest.kt +254 -0
  45. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesJavaCompatibilityTest.java +87 -0
  46. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesTest.kt +260 -0
  47. package/android/src/test/java/io/invertase/firebase/common/SharedUtilsJavaCompatibilityTest.java +255 -0
  48. package/android/src/test/java/io/invertase/firebase/common/SharedUtilsTest.kt +674 -0
  49. package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.kt +290 -0
  50. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebaseModuleJavaCompatibilityTest.java +178 -0
  51. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesJavaCompatibilityTest.java +99 -0
  52. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesTest.kt +217 -0
  53. package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleJavaCompatibilityTest.java +176 -0
  54. package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleKotlinCompatibilityTest.kt +52 -0
  55. package/android/src/test/java/io/invertase/firebase/interfaces/InterfacesJavaCompatibilityTest.java +144 -0
  56. package/android/src/test/java/io/invertase/firebase/interfaces/NativeEventTest.kt +56 -0
  57. package/android/src/test/java/io/invertase/firebase/utils/NativeRNFBTurboUtilsTest.java +517 -21
  58. package/dist/module/FirebaseApp.js +10 -0
  59. package/dist/module/FirebaseApp.js.map +1 -1
  60. package/dist/module/common/deeps.js +3 -0
  61. package/dist/module/common/deeps.js.map +1 -1
  62. package/dist/module/internal/FirebaseModule.js.map +1 -1
  63. package/dist/module/internal/RNFBNativeEventEmitter.js +12 -1
  64. package/dist/module/internal/RNFBNativeEventEmitter.js.map +1 -1
  65. package/dist/module/internal/SharedEventEmitter.js +3 -1
  66. package/dist/module/internal/SharedEventEmitter.js.map +1 -1
  67. package/dist/module/internal/index.js +1 -0
  68. package/dist/module/internal/index.js.map +1 -1
  69. package/dist/module/internal/registry/app.js +7 -1
  70. package/dist/module/internal/registry/app.js.map +1 -1
  71. package/dist/module/types/app.js.map +1 -1
  72. package/dist/module/types/internal.js +2 -0
  73. package/dist/module/version.js +1 -1
  74. package/dist/typescript/lib/FirebaseApp.d.ts +7 -0
  75. package/dist/typescript/lib/FirebaseApp.d.ts.map +1 -1
  76. package/dist/typescript/lib/common/deeps.d.ts.map +1 -1
  77. package/dist/typescript/lib/internal/FirebaseModule.d.ts +2 -3
  78. package/dist/typescript/lib/internal/FirebaseModule.d.ts.map +1 -1
  79. package/dist/typescript/lib/internal/NativeModules.d.ts +4 -1
  80. package/dist/typescript/lib/internal/NativeModules.d.ts.map +1 -1
  81. package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts +2 -2
  82. package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts.map +1 -1
  83. package/dist/typescript/lib/internal/SharedEventEmitter.d.ts +3 -3
  84. package/dist/typescript/lib/internal/SharedEventEmitter.d.ts.map +1 -1
  85. package/dist/typescript/lib/internal/index.d.ts +1 -0
  86. package/dist/typescript/lib/internal/index.d.ts.map +1 -1
  87. package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
  88. package/dist/typescript/lib/types/app.d.ts +10 -3
  89. package/dist/typescript/lib/types/app.d.ts.map +1 -1
  90. package/dist/typescript/lib/types/internal.d.ts +12 -0
  91. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  92. package/dist/typescript/lib/version.d.ts +1 -1
  93. package/firebase-schema.json +4 -0
  94. package/firebase_spm.rb +552 -96
  95. package/ios/RNFBApp/RCTConvert+FIRApp.h +2 -5
  96. package/ios/RNFBApp/RCTConvert+FIRApp.m +11 -6
  97. package/ios/RNFBApp/RCTConvert+FIROptions.h +2 -5
  98. package/ios/RNFBApp/RCTConvert+FIROptions.m +11 -10
  99. package/ios/RNFBApp/RCTConvertFIRApp.swift +86 -0
  100. package/ios/RNFBApp/RCTConvertFIROptions.swift +259 -0
  101. package/ios/RNFBApp/RNFBAppCustomAuthDomains.swift +63 -0
  102. package/ios/RNFBApp/RNFBAppInitializeOptionsMapper.swift +113 -0
  103. package/ios/RNFBApp/RNFBAppLogLevelMapper.swift +53 -0
  104. package/ios/RNFBApp/RNFBAppModule+CustomAuthDomain.m +35 -0
  105. package/ios/RNFBApp/RNFBAppModule.h +6 -2
  106. package/ios/RNFBApp/RNFBAppModule.mm +65 -228
  107. package/ios/RNFBApp/RNFBAppModuleFirebase.swift +439 -0
  108. package/ios/RNFBApp/RNFBAppModuleImplementation.h +68 -0
  109. package/ios/RNFBApp/RNFBAppModuleImplementation.m +195 -0
  110. package/ios/RNFBApp/RNFBHandleMap.m +27 -56
  111. package/ios/RNFBApp/RNFBHandleMapStorage.swift +90 -0
  112. package/ios/RNFBApp/RNFBInitializeAppArguments.swift +82 -0
  113. package/ios/RNFBApp/RNFBJSON.m +22 -38
  114. package/ios/RNFBApp/RNFBJSONImplementation.swift +71 -0
  115. package/ios/RNFBApp/RNFBMeta.m +24 -26
  116. package/ios/RNFBApp/RNFBMetaStorage.swift +76 -0
  117. package/ios/RNFBApp/RNFBNullSentinelDecoding.swift +135 -0
  118. package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +30 -3
  119. package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +28 -5
  120. package/ios/RNFBApp/RNFBPreferences.m +22 -20
  121. package/ios/RNFBApp/RNFBPreferencesStorage.swift +101 -0
  122. package/ios/RNFBApp/RNFBRCTEventEmitter.m +36 -93
  123. package/ios/RNFBApp/RNFBRCTEventEmitterCore.swift +161 -0
  124. package/ios/RNFBApp/RNFBSharedUtils.h +2 -5
  125. package/ios/RNFBApp/RNFBSharedUtils.m +109 -198
  126. package/ios/RNFBApp/RNFBSharedUtilsConfig.swift +72 -0
  127. package/ios/RNFBApp/RNFBSharedUtilsFIRApp.swift +271 -0
  128. package/ios/RNFBApp/RNFBSharedUtilsFormatting.swift +59 -0
  129. package/ios/RNFBApp/RNFBSharedUtilsPromiseRejection.swift +88 -0
  130. package/ios/RNFBApp/RNFBUtilsHelpers.swift +116 -0
  131. package/ios/RNFBApp/RNFBUtilsModule+Foundation.m +44 -0
  132. package/ios/RNFBApp/RNFBUtilsModule+PhotoAssets.m +47 -0
  133. package/ios/RNFBApp/RNFBUtilsModule.h +11 -1
  134. package/ios/RNFBApp/RNFBUtilsModule.mm +10 -85
  135. package/ios/RNFBApp/RNFBUtilsModuleImplementation.h +32 -0
  136. package/ios/RNFBApp/RNFBUtilsModuleImplementation.m +56 -0
  137. package/ios/RNFBApp/RNFBVersion.m +1 -1
  138. package/ios/RNFBApp.xcodeproj/project.pbxproj +100 -0
  139. package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FIRApp.m +171 -0
  140. package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FirebaseCore.h +78 -0
  141. package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FIRInstallations.m +7 -0
  142. package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FirebaseInstallations.h +8 -0
  143. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppModuleHostStub.m +55 -0
  144. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.h +89 -0
  145. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.mm +30 -0
  146. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.h +19 -0
  147. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.m +32 -0
  148. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridgeModule.h +19 -0
  149. package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.h +28 -0
  150. package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.m +23 -0
  151. package/ios/RNFBAppUnitTests/HostStubs/React/RCTEventEmitter.h +9 -0
  152. package/ios/RNFBAppUnitTests/HostStubs/React/RCTInvalidating.h +24 -0
  153. package/ios/RNFBAppUnitTests/HostStubs/React/RCTUtils.h +9 -0
  154. package/ios/RNFBAppUnitTests/HostStubs/module.modulemap +13 -0
  155. package/ios/RNFBAppUnitTests/RCTConvertFIRAppFacadeTests.m +61 -0
  156. package/ios/RNFBAppUnitTests/RCTConvertFIRAppTests.swift +73 -0
  157. package/ios/RNFBAppUnitTests/RCTConvertFIROptionsFacadeTests.m +57 -0
  158. package/ios/RNFBAppUnitTests/RCTConvertFIROptionsTests.swift +243 -0
  159. package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsFacadeTests.m +73 -0
  160. package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsTests.swift +70 -0
  161. package/ios/RNFBAppUnitTests/RNFBAppInitializeOptionsMapperTests.swift +190 -0
  162. package/ios/RNFBAppUnitTests/RNFBAppLogLevelFacadeTests.m +76 -0
  163. package/ios/RNFBAppUnitTests/RNFBAppLogLevelMapperTests.swift +59 -0
  164. package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseFacadeTests.m +215 -0
  165. package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseTests.swift +430 -0
  166. package/ios/RNFBAppUnitTests/RNFBAppModuleLifecycleTests.m +206 -0
  167. package/ios/RNFBAppUnitTests/RNFBAppModuleShellTests.mm +367 -0
  168. package/ios/RNFBAppUnitTests/RNFBAppUnitTests.xcodeproj/project.pbxproj +355 -2
  169. package/ios/RNFBAppUnitTests/RNFBFirebaseAppClientTests.swift +165 -0
  170. package/ios/RNFBAppUnitTests/RNFBHandleMapStorageTests.swift +121 -0
  171. package/ios/RNFBAppUnitTests/RNFBInitializeAppArgumentsTests.swift +256 -0
  172. package/ios/RNFBAppUnitTests/RNFBJSONImplementationTests.swift +126 -0
  173. package/ios/RNFBAppUnitTests/RNFBJSONTests.m +172 -0
  174. package/ios/RNFBAppUnitTests/RNFBMetaStorageTests.swift +106 -0
  175. package/ios/RNFBAppUnitTests/RNFBMetaTests.m +65 -0
  176. package/ios/RNFBAppUnitTests/RNFBNullSentinelDecodingTests.swift +286 -0
  177. package/ios/RNFBAppUnitTests/RNFBNullSentinelInterceptorTests.m +312 -0
  178. package/ios/RNFBAppUnitTests/RNFBPreferencesStorageTests.swift +105 -0
  179. package/ios/RNFBAppUnitTests/RNFBPreferencesTests.m +110 -0
  180. package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterCoreTests.swift +163 -0
  181. package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterFacadeTests.m +141 -0
  182. package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigFacadeTests.m +100 -0
  183. package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigTests.swift +234 -0
  184. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppFacadeTests.m +145 -0
  185. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppTests.swift +173 -0
  186. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingFacadeTests.m +38 -0
  187. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingTests.swift +82 -0
  188. package/ios/RNFBAppUnitTests/RNFBSharedUtilsNullSentinelTests.m +35 -0
  189. package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionFacadeTests.m +107 -0
  190. package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionTests.swift +133 -0
  191. package/ios/RNFBAppUnitTests/RNFBUtilsHelpersTests.swift +144 -0
  192. package/ios/RNFBAppUnitTests/RNFBUtilsModuleFacadeTests.m +72 -0
  193. package/ios/RNFBAppUnitTests/RNFBUtilsModuleShellTests.mm +282 -0
  194. package/ios/RNFBFirebase/Package.swift +53 -0
  195. package/ios/RNFBFirebase/Sources/RNFBFirebase/RNFBFirebase.swift +285 -0
  196. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/Public/.gitkeep +0 -0
  197. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/RNFBFirebaseBridge.m +169 -0
  198. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/include/RNFBFirebaseBridge.h +52 -0
  199. package/ios/RNFBFirebaseUnitTests/RNFBAppDynamicFacadeTests.swift +240 -0
  200. package/{android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.java → ios/RNFBFirebaseUnitTests/RNFBFirebaseClientImport.swift} +23 -14
  201. package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/project.pbxproj +588 -0
  202. package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBFirebaseUnitTests.xcscheme +83 -0
  203. package/ios_config.sh +50 -22
  204. package/lib/FirebaseApp.ts +10 -0
  205. package/lib/common/deeps.ts +3 -0
  206. package/lib/internal/FirebaseModule.ts +6 -3
  207. package/lib/internal/NativeModules.ts +4 -1
  208. package/lib/internal/RNFBNativeEventEmitter.ts +14 -5
  209. package/lib/internal/SharedEventEmitter.ts +5 -1
  210. package/lib/internal/index.ts +1 -0
  211. package/lib/internal/react-native-vendor-emitter.d.ts +11 -0
  212. package/lib/internal/registry/app.ts +7 -1
  213. package/lib/types/app.ts +10 -3
  214. package/lib/types/internal.ts +19 -0
  215. package/lib/version.ts +1 -1
  216. package/package.json +8 -8
  217. package/plugin/build/ios/appDelegate.js +2 -2
  218. package/plugin/build/ios/podfile.js +16 -16
  219. package/plugin/build/pluginConfig.d.ts +4 -2
  220. package/plugin/src/ios/appDelegate.ts +2 -2
  221. package/plugin/src/ios/podfile.ts +20 -23
  222. package/plugin/src/pluginConfig.ts +4 -2
  223. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.java +0 -150
  224. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +0 -148
  225. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +0 -62
  226. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +0 -91
  227. package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.java +0 -224
  228. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +0 -46
  229. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +0 -49
  230. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +0 -35
  231. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +0 -192
  232. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +0 -53
  233. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +0 -606
  234. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +0 -109
  235. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +0 -101
  236. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +0 -146
  237. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +0 -96
  238. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +0 -441
  239. package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.java +0 -223
  240. package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.java +0 -275
  241. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.java +0 -108
  242. package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.java +0 -97
@@ -1,109 +0,0 @@
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 com.facebook.react.bridge.Arguments;
21
- import com.facebook.react.bridge.WritableMap;
22
- import io.invertase.firebase.BuildConfig;
23
- import java.util.ArrayList;
24
- import java.util.Iterator;
25
- import org.json.JSONArray;
26
- import org.json.JSONException;
27
- import org.json.JSONObject;
28
-
29
- public class ReactNativeFirebaseJSON {
30
- private static ReactNativeFirebaseJSON sharedInstance = new ReactNativeFirebaseJSON();
31
-
32
- private JSONObject jsonObject;
33
-
34
- private ReactNativeFirebaseJSON() {
35
- try {
36
- jsonObject = new JSONObject(BuildConfig.FIREBASE_JSON_RAW);
37
- } catch (JSONException e) {
38
- // JSON is validated as part of gradle build - should never error
39
- }
40
- }
41
-
42
- public static ReactNativeFirebaseJSON getSharedInstance() {
43
- return sharedInstance;
44
- }
45
-
46
- public boolean contains(String key) {
47
- if (jsonObject == null) return false;
48
- return jsonObject.has(key);
49
- }
50
-
51
- public boolean getBooleanValue(String key, boolean defaultValue) {
52
- if (jsonObject == null) return defaultValue;
53
- return jsonObject.optBoolean(key, defaultValue);
54
- }
55
-
56
- public int getIntValue(String key, int defaultValue) {
57
- if (jsonObject == null) return defaultValue;
58
- return jsonObject.optInt(key, defaultValue);
59
- }
60
-
61
- public long getLongValue(String key, long defaultValue) {
62
- if (jsonObject == null) return defaultValue;
63
- return jsonObject.optLong(key, defaultValue);
64
- }
65
-
66
- public String getStringValue(String key, String defaultValue) {
67
- if (jsonObject == null) return defaultValue;
68
- return jsonObject.optString(key, defaultValue);
69
- }
70
-
71
- public ArrayList<String> getArrayValue(String key) {
72
- ArrayList<String> result = new ArrayList<String>();
73
- if (jsonObject == null) return result;
74
-
75
- try {
76
- JSONArray array = jsonObject.optJSONArray(key);
77
- if (array != null) {
78
- for (int i = 0; i < array.length(); i++) {
79
- result.add(array.getString(i));
80
- }
81
- }
82
- } catch (JSONException e) {
83
- // do nothing
84
- }
85
-
86
- return result;
87
- }
88
-
89
- public String getRawJSON() {
90
- return BuildConfig.FIREBASE_JSON_RAW;
91
- }
92
-
93
- public WritableMap getAll() {
94
- WritableMap writableMap = Arguments.createMap();
95
- if (jsonObject == null) return writableMap;
96
-
97
- Iterator<String> keys = jsonObject.keys();
98
- while (keys.hasNext()) {
99
- try {
100
- String key = keys.next();
101
- SharedUtils.mapPutValue(key, jsonObject.get(key), writableMap);
102
- } catch (JSONException e) {
103
- // ignore
104
- }
105
- }
106
-
107
- return writableMap;
108
- }
109
- }
@@ -1,101 +0,0 @@
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.content.Context;
21
- import android.content.pm.ApplicationInfo;
22
- import android.content.pm.PackageManager;
23
- import android.os.Bundle;
24
- import com.facebook.react.bridge.Arguments;
25
- import com.facebook.react.bridge.WritableMap;
26
- import io.invertase.firebase.app.ReactNativeFirebaseApp;
27
-
28
- public class ReactNativeFirebaseMeta {
29
- private static final String TAG = "RNFBMetaProvider";
30
- private static final String META_PREFIX = "rnfirebase_";
31
- private static ReactNativeFirebaseMeta sharedInstance = new ReactNativeFirebaseMeta();
32
-
33
- public static ReactNativeFirebaseMeta getSharedInstance() {
34
- return sharedInstance;
35
- }
36
-
37
- private Bundle getMetaData() {
38
- try {
39
- Context context = ReactNativeFirebaseApp.getApplicationContext();
40
- PackageManager packageManager = context.getPackageManager();
41
-
42
- if (packageManager == null) return null;
43
-
44
- ApplicationInfo applicationInfo =
45
- packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
46
-
47
- if (applicationInfo != null) return applicationInfo.metaData;
48
- } catch (PackageManager.NameNotFoundException exception) {
49
- // do nothing
50
- }
51
-
52
- return null;
53
- }
54
-
55
- public boolean contains(String key) {
56
- Bundle metaData = getMetaData();
57
- if (metaData == null) return false;
58
- return metaData.containsKey(META_PREFIX + key);
59
- }
60
-
61
- public boolean getBooleanValue(String key, boolean defaultValue) {
62
- Bundle metaData = getMetaData();
63
- if (metaData == null) return defaultValue;
64
- return metaData.getBoolean(META_PREFIX + key, defaultValue);
65
- }
66
-
67
- public String getStringValue(String key, String defaultValue) {
68
- Bundle metaData = getMetaData();
69
- if (metaData == null) return defaultValue;
70
- return metaData.getString(META_PREFIX + key, defaultValue);
71
- }
72
-
73
- public int getIntValue(String key, int defaultValue) {
74
- Bundle metaData = getMetaData();
75
- if (metaData == null) return defaultValue;
76
- return metaData.getInt(META_PREFIX + key, defaultValue);
77
- }
78
-
79
- public WritableMap getAll() {
80
- Bundle metaData = getMetaData();
81
- WritableMap map = Arguments.createMap();
82
- if (metaData == null) return map;
83
-
84
- for (String key : metaData.keySet()) {
85
- if (key.startsWith(META_PREFIX)) {
86
- Object value = metaData.get(key);
87
- if (value == null) {
88
- map.putNull(key);
89
- } else if (value instanceof String) {
90
- map.putString(key, (String) value);
91
- } else if (value instanceof Boolean) {
92
- map.putBoolean(key, (Boolean) value);
93
- } else if (value instanceof Integer) {
94
- map.putInt(key, (Integer) value);
95
- }
96
- }
97
- }
98
-
99
- return map;
100
- }
101
- }
@@ -1,146 +0,0 @@
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.app.Activity;
21
- import android.content.Context;
22
- import androidx.annotation.CallSuper;
23
- import androidx.annotation.NonNull;
24
- import com.facebook.react.bridge.*;
25
- import io.invertase.firebase.interfaces.ContextProvider;
26
- import java.util.HashMap;
27
- import java.util.Map;
28
- import java.util.concurrent.ExecutorService;
29
-
30
- public class ReactNativeFirebaseModule extends ReactContextBaseJavaModule
31
- implements ContextProvider {
32
- private final TaskExecutorService executorService;
33
-
34
- private String moduleName;
35
-
36
- public ReactNativeFirebaseModule(ReactApplicationContext reactContext, String moduleName) {
37
- super(reactContext);
38
- this.moduleName = moduleName;
39
- this.executorService = new TaskExecutorService(getName());
40
- }
41
-
42
- public static void rejectPromiseWithExceptionMap(Promise promise, Exception exception) {
43
- promise.reject(exception, SharedUtils.getExceptionMap(exception));
44
- }
45
-
46
- public static void rejectPromiseWithCodeAndMessage(
47
- Promise promise, String code, String message, ReadableMap resolver) {
48
- WritableMap userInfoMap = Arguments.createMap();
49
- userInfoMap.putString("code", code);
50
- userInfoMap.putString("message", message);
51
- if (resolver != null) {
52
- userInfoMap.putMap("resolver", resolver);
53
- }
54
- promise.reject(code, message, userInfoMap);
55
- }
56
-
57
- public static void rejectPromiseWithCodeAndMessage(Promise promise, String code, String message) {
58
- WritableMap userInfoMap = Arguments.createMap();
59
- userInfoMap.putString("code", code);
60
- userInfoMap.putString("message", message);
61
- promise.reject(code, message, userInfoMap);
62
- }
63
-
64
- public static void rejectPromiseWithCodeAndMessage(
65
- Promise promise, String code, String message, String nativeErrorMessage) {
66
- WritableMap userInfoMap = Arguments.createMap();
67
- userInfoMap.putString("code", code);
68
- userInfoMap.putString("message", message);
69
- userInfoMap.putString("nativeErrorMessage", nativeErrorMessage);
70
- promise.reject(code, message, userInfoMap);
71
- }
72
-
73
- @Override
74
- @CallSuper
75
- public void initialize() {
76
- super.initialize();
77
- }
78
-
79
- public ReactContext getContext() {
80
- return getReactApplicationContext();
81
- }
82
-
83
- public final ExecutorService getExecutor() {
84
- return executorService.getExecutor();
85
- }
86
-
87
- public final ExecutorService getTransactionalExecutor() {
88
- return executorService.getTransactionalExecutor();
89
- }
90
-
91
- public final ExecutorService getTransactionalExecutor(String identifier) {
92
- return executorService.getTransactionalExecutor(identifier);
93
- }
94
-
95
- // On react-native 0.73 this is called, but simply calls `invalidate()`
96
- // https://github.com/facebook/react-native/blob/0.73-stable/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseJavaModule.java#L65-L72
97
- // This is no longer called ever for react-native >= 0.74 and is only here for
98
- // compatibility with older versions. We delegate to the new `invalidate`
99
- // method, which all modules should implement now
100
- // Remove this method when minimum supported react-native is 0.74
101
- // @noinspection removal
102
- @SuppressWarnings({"deprecation", "removal"})
103
- @Deprecated
104
- public void onCatalystInstanceDestroy() {
105
- // This should call the child class invalidate, which will then call super.invalidate,
106
- // and everything will work correctly up and down the inheritance hierarchy to shut down
107
- invalidate();
108
- }
109
-
110
- // This should have an @Override annotation but we cannot do
111
- // that until our minimum supported react-native version is 0.74
112
- //
113
- // No need to call super.invalidate and in fact it is dangerous to do so:
114
- // - did not exist before react-native 0.73
115
- // - on 0.74 it calls onCatalystInstanceDestroy which would infinite loop here
116
- // - on 0.75+ it is empty - meant as sub-class hook only
117
- @CallSuper
118
- public void invalidate() {
119
- executorService.shutdown();
120
- }
121
-
122
- public final void removeEventListeningExecutor(String identifier) {
123
- String executorName = executorService.getExecutorName(true, identifier);
124
- executorService.removeExecutor(executorName);
125
- }
126
-
127
- public Context getApplicationContext() {
128
- return getReactApplicationContext().getApplicationContext();
129
- }
130
-
131
- public Activity getActivity() {
132
- return getCurrentActivity();
133
- }
134
-
135
- @NonNull
136
- @Override
137
- public String getName() {
138
- return "RNFB" + moduleName + "Module";
139
- }
140
-
141
- @NonNull
142
- @Override
143
- public Map<String, Object> getConstants() {
144
- return new HashMap<>();
145
- }
146
- }
@@ -1,96 +0,0 @@
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.content.Context;
21
- import android.content.SharedPreferences;
22
- import com.facebook.react.bridge.Arguments;
23
- import com.facebook.react.bridge.WritableMap;
24
- import io.invertase.firebase.app.ReactNativeFirebaseApp;
25
- import java.util.Map;
26
-
27
- public class ReactNativeFirebasePreferences {
28
- private static final String PREFERENCES_FILE = "io.invertase.firebase";
29
- private static ReactNativeFirebasePreferences sharedInstance =
30
- new ReactNativeFirebasePreferences();
31
- private SharedPreferences preferences;
32
-
33
- public static ReactNativeFirebasePreferences getSharedInstance() {
34
- return sharedInstance;
35
- }
36
-
37
- public boolean contains(String key) {
38
- return getPreferences().contains(key);
39
- }
40
-
41
- public void setBooleanValue(String key, boolean value) {
42
- getPreferences().edit().putBoolean(key, value).apply();
43
- }
44
-
45
- public boolean getBooleanValue(String key, boolean defaultValue) {
46
- return getPreferences().getBoolean(key, defaultValue);
47
- }
48
-
49
- public void setIntValue(String key, int value) {
50
- getPreferences().edit().putInt(key, value).apply();
51
- }
52
-
53
- public int getIntValue(String key, int defaultValue) {
54
- return getPreferences().getInt(key, defaultValue);
55
- }
56
-
57
- public void setLongValue(String key, long value) {
58
- getPreferences().edit().putLong(key, value).apply();
59
- }
60
-
61
- public long getLongValue(String key, long defaultValue) {
62
- return getPreferences().getLong(key, defaultValue);
63
- }
64
-
65
- public void setStringValue(String key, String value) {
66
- getPreferences().edit().putString(key, value).apply();
67
- }
68
-
69
- public String getStringValue(String key, String defaultValue) {
70
- return getPreferences().getString(key, defaultValue);
71
- }
72
-
73
- public WritableMap getAll() {
74
- WritableMap writableMap = Arguments.createMap();
75
- Map<String, ?> prefMap = getPreferences().getAll();
76
-
77
- for (Map.Entry<String, ?> entry : prefMap.entrySet()) {
78
- SharedUtils.mapPutValue(entry.getKey(), entry.getValue(), writableMap);
79
- }
80
-
81
- return writableMap;
82
- }
83
-
84
- public void clearAll() {
85
- getPreferences().edit().clear().apply();
86
- }
87
-
88
- private SharedPreferences getPreferences() {
89
- if (preferences == null) {
90
- preferences =
91
- ReactNativeFirebaseApp.getApplicationContext()
92
- .getSharedPreferences(PREFERENCES_FILE, Context.MODE_PRIVATE);
93
- }
94
- return preferences;
95
- }
96
- }