@react-native-firebase/app 26.4.0 → 27.0.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 +48 -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
@@ -0,0 +1,250 @@
1
+ package io.invertase.firebase.app
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.util.Log
21
+ import com.facebook.fbreact.specs.NativeRNFBTurboAppSpec
22
+ import com.facebook.react.bridge.LifecycleEventListener
23
+ import com.facebook.react.bridge.Promise
24
+ import com.facebook.react.bridge.ReactApplicationContext
25
+ import com.facebook.react.bridge.ReadableMap
26
+ import com.google.firebase.FirebaseApp
27
+ import io.invertase.firebase.common.RCTConvertFirebase
28
+ import io.invertase.firebase.common.ReactNativeFirebaseEvent
29
+ import io.invertase.firebase.common.ReactNativeFirebaseEventEmitter
30
+ import io.invertase.firebase.common.ReactNativeFirebaseJSON
31
+ import io.invertase.firebase.common.ReactNativeFirebaseMeta
32
+ import io.invertase.firebase.common.ReactNativeFirebasePreferences
33
+ import java.util.ArrayList
34
+ import java.util.HashMap
35
+ import java.util.concurrent.ConcurrentHashMap
36
+
37
+ open class NativeRNFBTurboApp protected constructor(
38
+ reactContext: ReactApplicationContext?,
39
+ ) : NativeRNFBTurboAppSpec(reactContext),
40
+ LifecycleEventListener {
41
+ override fun initialize() {
42
+ super.initialize()
43
+ val reactContext = reactApplicationContext
44
+ // Register unconditionally. When the host is already RESUMED, addLifecycleEventListener
45
+ // posts onHostResume onto the UI queue asynchronously (it is not a synchronous call), so
46
+ // the explicit attach below is the primary path; resume remains best-effort convergence
47
+ // for later host flips. Stale-generation attaches are rejected or held pending by
48
+ // attachReactContext's fail-closed current-context arbitration.
49
+ reactContext.addLifecycleEventListener(this)
50
+ ReactNativeFirebaseEventEmitter.getSharedInstance().attachReactContext(reactContext)
51
+ }
52
+
53
+ override fun invalidate() {
54
+ val reactContext = reactApplicationContext
55
+ reactContext.removeLifecycleEventListener(this)
56
+ // Identity-guarded inside the emitter: only clears state belonging to this dying context,
57
+ // never state a replacement runtime has already installed.
58
+ ReactNativeFirebaseEventEmitter.getSharedInstance().detachReactContext(reactContext)
59
+ super.invalidate()
60
+ }
61
+
62
+ override fun onHostResume() {
63
+ // Re-attaching also flushes any events queued while no runtime was able to receive them.
64
+ ReactNativeFirebaseEventEmitter
65
+ .getSharedInstance()
66
+ .attachReactContext(reactApplicationContext)
67
+ }
68
+
69
+ override fun onHostPause() {
70
+ // No-op, required by LifecycleEventListener.
71
+ }
72
+
73
+ override fun onHostDestroy() {
74
+ // No-op, required by LifecycleEventListener.
75
+ }
76
+
77
+ protected override fun getTypedExportedConstants(): MutableMap<String, Any?> {
78
+ val constants: MutableMap<String, Any?> = HashMap()
79
+ val appsList: MutableList<Map<String, Any?>> = ArrayList()
80
+ val firebaseApps = FirebaseApp.getApps(reactApplicationContext)
81
+
82
+ for (app in firebaseApps) {
83
+ appsList.add(RCTConvertFirebase.firebaseAppToMap(app))
84
+ }
85
+
86
+ constants["NATIVE_FIREBASE_APPS"] = appsList
87
+ constants["FIREBASE_RAW_JSON"] = ReactNativeFirebaseJSON.getSharedInstance().getRawJSON()
88
+
89
+ return constants
90
+ }
91
+
92
+ override fun initializeApp(
93
+ options: ReadableMap?,
94
+ appConfig: ReadableMap?,
95
+ promise: Promise?,
96
+ ) {
97
+ val firebaseApp =
98
+ RCTConvertFirebase.readableMapToFirebaseApp(options, appConfig, reactApplicationContext)
99
+ configureAuthDomain(
100
+ nullableAsPlatformType<ReadableMap>(appConfig).getString("name"),
101
+ nullableAsPlatformType<ReadableMap>(options).getString("authDomain"),
102
+ )
103
+
104
+ val firebaseAppMap = RCTConvertFirebase.firebaseAppToWritableMap(firebaseApp)
105
+ nullableAsPlatformType<Promise>(promise).resolve(firebaseAppMap)
106
+ }
107
+
108
+ override fun setAutomaticDataCollectionEnabled(
109
+ appName: String?,
110
+ enabled: Boolean,
111
+ ) {
112
+ val firebaseApp: FirebaseApp? = FirebaseApp.getInstance(nullableAsPlatformType(appName))
113
+ nullableAsPlatformType<FirebaseApp>(firebaseApp).setDataCollectionDefaultEnabled(enabled)
114
+ }
115
+
116
+ override fun deleteApp(
117
+ appName: String?,
118
+ promise: Promise?,
119
+ ) {
120
+ val firebaseApp: FirebaseApp? = FirebaseApp.getInstance(nullableAsPlatformType(appName))
121
+
122
+ if (firebaseApp != null) {
123
+ firebaseApp.delete()
124
+ authDomains.remove(appName)
125
+ }
126
+
127
+ nullableAsPlatformType<Promise>(promise).resolve(null)
128
+ }
129
+
130
+ override fun eventsNotifyReady(ready: Boolean) {
131
+ val emitter = ReactNativeFirebaseEventEmitter.getSharedInstance()
132
+ emitter.notifyJsReady(ready)
133
+ }
134
+
135
+ override fun eventsGetListeners(promise: Promise?) {
136
+ val emitter = ReactNativeFirebaseEventEmitter.getSharedInstance()
137
+ nullableAsPlatformType<Promise>(promise).resolve(emitter.listenersMap)
138
+ }
139
+
140
+ override fun eventsPing(
141
+ eventName: String?,
142
+ eventBody: ReadableMap?,
143
+ promise: Promise?,
144
+ ) {
145
+ val emitter = ReactNativeFirebaseEventEmitter.getSharedInstance()
146
+ emitter.sendEvent(
147
+ ReactNativeFirebaseEvent(
148
+ nullableAsPlatformType(eventName),
149
+ nullableAsPlatformType(RCTConvertFirebase.readableMapToWritableMap(eventBody)),
150
+ ),
151
+ )
152
+ nullableAsPlatformType<Promise>(promise).resolve(
153
+ RCTConvertFirebase.readableMapToWritableMap(eventBody),
154
+ )
155
+ }
156
+
157
+ override fun eventsAddListener(eventName: String?) {
158
+ val emitter = ReactNativeFirebaseEventEmitter.getSharedInstance()
159
+ emitter.addListener(eventName)
160
+ }
161
+
162
+ override fun eventsRemoveListener(
163
+ eventName: String?,
164
+ all: Boolean,
165
+ ) {
166
+ val emitter = ReactNativeFirebaseEventEmitter.getSharedInstance()
167
+ emitter.removeListener(eventName, all)
168
+ }
169
+
170
+ override fun addListener(eventName: String?) {
171
+ // Keep: Required for RN built in Event Emitter Calls.
172
+ }
173
+
174
+ override fun removeListeners(count: Double) {
175
+ // Keep: Required for RN built in Event Emitter Calls.
176
+ }
177
+
178
+ override fun metaGetAll(promise: Promise?) {
179
+ nullableAsPlatformType<Promise>(promise).resolve(
180
+ ReactNativeFirebaseMeta.getSharedInstance().getAll(),
181
+ )
182
+ }
183
+
184
+ override fun jsonGetAll(promise: Promise?) {
185
+ nullableAsPlatformType<Promise>(promise).resolve(
186
+ ReactNativeFirebaseJSON.getSharedInstance().getAll(),
187
+ )
188
+ }
189
+
190
+ override fun preferencesSetBool(
191
+ key: String?,
192
+ value: Boolean,
193
+ promise: Promise?,
194
+ ) {
195
+ ReactNativeFirebasePreferences.getSharedInstance().setBooleanValue(key, value)
196
+ nullableAsPlatformType<Promise>(promise).resolve(null)
197
+ }
198
+
199
+ override fun preferencesSetString(
200
+ key: String?,
201
+ value: String?,
202
+ promise: Promise?,
203
+ ) {
204
+ ReactNativeFirebasePreferences.getSharedInstance().setStringValue(key, value)
205
+ nullableAsPlatformType<Promise>(promise).resolve(null)
206
+ }
207
+
208
+ override fun preferencesGetAll(promise: Promise?) {
209
+ nullableAsPlatformType<Promise>(promise).resolve(
210
+ ReactNativeFirebasePreferences.getSharedInstance().getAll(),
211
+ )
212
+ }
213
+
214
+ override fun preferencesClearAll(promise: Promise?) {
215
+ ReactNativeFirebasePreferences.getSharedInstance().clearAll()
216
+ nullableAsPlatformType<Promise>(promise).resolve(null)
217
+ }
218
+
219
+ override fun setLogLevel(logLevel: String?) {
220
+ // Android uses Firebase SDK log level via manifest; no-op at runtime.
221
+ }
222
+
223
+ companion object {
224
+ private const val TAG = "App"
225
+
226
+ @JvmField
227
+ val authDomains: MutableMap<String?, String> = ConcurrentHashMap()
228
+
229
+ // Kotlin has no package-private constructor. Protected keeps same-package Java construction
230
+ // while avoiding an externally public constructor; this internal invoke keeps same-module
231
+ // Kotlin package registration source-compatible without widening the constructor itself.
232
+ internal operator fun invoke(reactContext: ReactApplicationContext?): NativeRNFBTurboApp = NativeRNFBTurboApp(reactContext)
233
+
234
+ @Suppress("UNCHECKED_CAST")
235
+ private fun <T> nullableAsPlatformType(value: T?): T = value as T
236
+
237
+ @JvmStatic
238
+ fun configureAuthDomain(
239
+ name: String?,
240
+ authDomain: String?,
241
+ ) {
242
+ if (authDomain != null) {
243
+ Log.d(TAG, "$name custom authDomain $authDomain")
244
+ authDomains[name] = authDomain
245
+ } else {
246
+ authDomains.remove(name)
247
+ }
248
+ }
249
+ }
250
+ }
@@ -0,0 +1,64 @@
1
+ package io.invertase.firebase.app
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
+ import android.content.Context
20
+ import android.util.Log
21
+ import com.google.firebase.FirebaseApp
22
+ import com.google.firebase.FirebaseOptions
23
+
24
+ open class ReactNativeFirebaseApp {
25
+ companion object {
26
+ private var applicationContext: Context? = null
27
+
28
+ @JvmStatic fun getApplicationContext(): Context = nullableAsPlatformType(applicationContext)
29
+
30
+ @JvmStatic
31
+ fun setApplicationContext(applicationContext: Context?) {
32
+ Log.d("ReactNativeFirebaseApp", "received application context.")
33
+ ReactNativeFirebaseApp.applicationContext = applicationContext
34
+ }
35
+
36
+ @JvmStatic
37
+ fun initializeSecondaryApp(name: String?) {
38
+ val context: Context = nullableAsPlatformType(applicationContext)
39
+ val options = FirebaseOptions.fromResource(context)
40
+ FirebaseApp.initializeApp(
41
+ context,
42
+ nullableAsPlatformType(options),
43
+ nullableAsPlatformType(name),
44
+ )
45
+ }
46
+
47
+ @JvmStatic
48
+ fun initializeSecondaryApp(
49
+ name: String?,
50
+ applicationContext: Context?,
51
+ ) {
52
+ val context: Context = nullableAsPlatformType(applicationContext)
53
+ val options = FirebaseOptions.fromResource(context)
54
+ FirebaseApp.initializeApp(
55
+ context,
56
+ nullableAsPlatformType(options),
57
+ nullableAsPlatformType(name),
58
+ )
59
+ }
60
+
61
+ @Suppress("UNCHECKED_CAST")
62
+ private fun <T> nullableAsPlatformType(value: T?): T = value as T
63
+ }
64
+ }
@@ -1,4 +1,4 @@
1
- package io.invertase.firebase.app;
1
+ package io.invertase.firebase.app
2
2
 
3
3
  /*
4
4
  * Copyright (c) 2016-present Invertase Limited & Contributors
@@ -14,9 +14,8 @@ package io.invertase.firebase.app;
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- *
18
17
  */
19
18
 
20
- import io.invertase.firebase.common.ReactNativeFirebaseInitProvider;
19
+ import io.invertase.firebase.common.ReactNativeFirebaseInitProvider
21
20
 
22
- public class ReactNativeFirebaseAppInitProvider extends ReactNativeFirebaseInitProvider {}
21
+ public open class ReactNativeFirebaseAppInitProvider : ReactNativeFirebaseInitProvider()
@@ -0,0 +1,47 @@
1
+ package io.invertase.firebase.app
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
+ import com.facebook.react.ReactPackage
20
+ import com.facebook.react.bridge.NativeModule
21
+ import com.facebook.react.bridge.ReactApplicationContext
22
+ import com.facebook.react.uimanager.ViewManager
23
+ import io.invertase.firebase.utils.NativeRNFBTurboUtils
24
+ import java.util.ArrayList
25
+ import java.util.Collections
26
+ import javax.annotation.Nonnull
27
+
28
+ @Suppress("unused")
29
+ open class ReactNativeFirebaseAppPackage : ReactPackage {
30
+ @Nonnull
31
+ override fun createNativeModules(
32
+ @Nonnull reactContext: ReactApplicationContext,
33
+ ): MutableList<NativeModule> {
34
+ if (ReactNativeFirebaseApp.getApplicationContext() == null) {
35
+ ReactNativeFirebaseApp.setApplicationContext(reactContext.applicationContext)
36
+ }
37
+ return ArrayList<NativeModule>().apply {
38
+ add(NativeRNFBTurboApp(reactContext))
39
+ add(NativeRNFBTurboUtils(reactContext))
40
+ }
41
+ }
42
+
43
+ @Nonnull
44
+ override fun createViewManagers(
45
+ @Nonnull reactContext: ReactApplicationContext,
46
+ ): MutableList<ViewManager<out Nothing, out Nothing>> = Collections.emptyList()
47
+ }
@@ -0,0 +1,33 @@
1
+ package io.invertase.firebase.app
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
+ import androidx.annotation.Keep
20
+ import com.google.firebase.components.Component
21
+ import com.google.firebase.components.ComponentRegistrar
22
+ import com.google.firebase.platforminfo.LibraryVersionComponent
23
+
24
+ @Keep
25
+ public open class ReactNativeFirebaseAppRegistrar : ComponentRegistrar {
26
+ override fun getComponents(): List<Component<*>> =
27
+ listOf(
28
+ LibraryVersionComponent.create(
29
+ "react-native-firebase",
30
+ ReactNativeFirebaseVersion.VERSION,
31
+ ),
32
+ )
33
+ }
@@ -18,5 +18,5 @@ package io.invertase.firebase.app;
18
18
  */
19
19
  // generated file - do not modify or commit
20
20
  public class ReactNativeFirebaseVersion {
21
- public static String VERSION = "26.4.0";
21
+ public static String VERSION = "27.0.0";
22
22
  }
@@ -0,0 +1,185 @@
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
+ import android.content.Context
20
+ import android.util.Log
21
+ import com.facebook.react.bridge.Arguments
22
+ import com.facebook.react.bridge.ReadableArray
23
+ import com.facebook.react.bridge.ReadableMap
24
+ import com.facebook.react.bridge.WritableMap
25
+ import com.google.firebase.FirebaseApp
26
+ import com.google.firebase.FirebaseOptions
27
+ import io.invertase.firebase.app.NativeRNFBTurboApp
28
+ import java.util.HashMap
29
+
30
+ /** Utilities to convert to and from React Native bridge formats. */
31
+ open class RCTConvertFirebase {
32
+ companion object {
33
+ private const val TAG = "RCTConvertFirebase"
34
+
35
+ @JvmStatic
36
+ fun firebaseAppToMap(firebaseApp: FirebaseApp?): Map<String, Any?> {
37
+ val name = firebaseApp!!.name
38
+ val appOptions = firebaseApp.options
39
+
40
+ val root = HashMap<String, Any?>()
41
+ val options = HashMap<String, Any?>()
42
+ val appConfig = HashMap<String, Any?>()
43
+
44
+ appConfig["name"] = name
45
+ appConfig["automaticDataCollectionEnabled"] =
46
+ firebaseApp.isDataCollectionDefaultEnabled
47
+
48
+ // TODO: Salakar: Firebase SDK does not support reading this value
49
+ // appConfig["automaticResourceManagement"] = false
50
+
51
+ options["apiKey"] = appOptions.apiKey
52
+ options["appId"] = appOptions.applicationId
53
+ options["projectId"] = appOptions.projectId
54
+ options["databaseURL"] = appOptions.databaseUrl
55
+ options["measurementId"] = appOptions.gaTrackingId
56
+ options["messagingSenderId"] = appOptions.gcmSenderId
57
+ options["storageBucket"] = appOptions.storageBucket
58
+
59
+ NativeRNFBTurboApp.authDomains[name]?.let { options["authDomain"] = it }
60
+
61
+ root["options"] = options
62
+ root["appConfig"] = appConfig
63
+
64
+ return root
65
+ }
66
+
67
+ @JvmStatic
68
+ fun firebaseAppToWritableMap(firebaseApp: FirebaseApp?): WritableMap? = Arguments.makeNativeMap(firebaseAppToMap(firebaseApp))
69
+
70
+ @JvmStatic
71
+ fun readableMapToFirebaseApp(
72
+ options: ReadableMap?,
73
+ appConfig: ReadableMap?,
74
+ context: Context?,
75
+ ): FirebaseApp? {
76
+ val builder = FirebaseOptions.Builder()
77
+ val name = appConfig!!.getString("name")
78
+
79
+ builder.setApiKey(options!!.getString("apiKey")!!)
80
+ builder.setApplicationId(options.getString("appId")!!)
81
+ builder.setProjectId(options.getString("projectId"))
82
+ builder.setDatabaseUrl(options.getString("databaseURL"))
83
+
84
+ if (options.hasKey("measurementId")) {
85
+ builder.setGaTrackingId(options.getString("measurementId"))
86
+ }
87
+
88
+ builder.setStorageBucket(options.getString("storageBucket"))
89
+ builder.setGcmSenderId(options.getString("messagingSenderId"))
90
+
91
+ val firebaseApp =
92
+ if (name!!.equals("[DEFAULT]")) {
93
+ FirebaseApp.initializeApp(context!!, builder.build())
94
+ } else {
95
+ FirebaseApp.initializeApp(context!!, builder.build(), name)
96
+ }
97
+
98
+ if (appConfig.hasKey("automaticDataCollectionEnabled")) {
99
+ firebaseApp!!.setDataCollectionDefaultEnabled(
100
+ appConfig.getBoolean("automaticDataCollectionEnabled"),
101
+ )
102
+ }
103
+
104
+ if (appConfig.hasKey("automaticResourceManagement")) {
105
+ // https://developers.google.com/android/reference/com/google/firebase/FirebaseApp.html#setAutomaticResourceManagementEnabled(boolean)
106
+ firebaseApp!!.setAutomaticResourceManagementEnabled(
107
+ appConfig.getBoolean("automaticResourceManagement"),
108
+ )
109
+ }
110
+
111
+ return firebaseApp
112
+ }
113
+
114
+ /**
115
+ * Takes a value and calls the appropriate setter for its type on the target map + key.
116
+ *
117
+ * @param key String key to set on target map
118
+ * @param value Object value to set on target map
119
+ * @param map WritableMap target map to write the value to
120
+ */
121
+ @JvmStatic
122
+ @Suppress("UNCHECKED_CAST")
123
+ fun mapPutValue(
124
+ key: String?,
125
+ value: Any?,
126
+ map: WritableMap?,
127
+ ): WritableMap? {
128
+ val target = map!!
129
+ if (value == null) {
130
+ target.putNull(key!!)
131
+ return map
132
+ }
133
+
134
+ val type = value.javaClass.name
135
+ val targetKey = key!!
136
+
137
+ when (type) {
138
+ "java.lang.Boolean" -> target.putBoolean(targetKey, value as Boolean)
139
+ "java.lang.Long" -> target.putDouble(targetKey, (value as Long).toDouble())
140
+ "java.lang.Float" -> target.putDouble(targetKey, (value as Float).toDouble())
141
+ "java.lang.Double" -> target.putDouble(targetKey, value as Double)
142
+ "java.lang.Integer" -> target.putInt(targetKey, value as Int)
143
+ "java.lang.String" -> target.putString(targetKey, value as String)
144
+ "org.json.JSONObject\$1" -> target.putString(targetKey, value.toString())
145
+ else ->
146
+ when (value) {
147
+ is List<*> ->
148
+ target.putArray(targetKey, Arguments.makeNativeArray(value as List<Any?>))
149
+ is Map<*, *> -> {
150
+ val childMap = Arguments.createMap()
151
+ for ((childKey, childValue) in value as Map<String, Any?>) {
152
+ mapPutValue(childKey, childValue, childMap)
153
+ }
154
+ target.putMap(targetKey, childMap)
155
+ }
156
+ else -> {
157
+ Log.d(TAG, "utils:mapPutValue:unknownType:$type")
158
+ target.putNull(targetKey)
159
+ }
160
+ }
161
+ }
162
+
163
+ return map
164
+ }
165
+
166
+ // TODO Remove me - also in SharedUtils
167
+ @JvmStatic
168
+ fun readableMapToWritableMap(map: ReadableMap?): WritableMap? {
169
+ val writableMap = Arguments.createMap()
170
+ // https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeMap.java#L54
171
+ writableMap.merge(map!!)
172
+ return writableMap
173
+ }
174
+
175
+ @JvmStatic
176
+ fun toHashMap(readableMap: ReadableMap?): Map<String, Any?>? =
177
+ // https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java#L216
178
+ readableMap!!.toHashMap()
179
+
180
+ @JvmStatic
181
+ fun toArrayList(readableArray: ReadableArray?): List<Any?>? =
182
+ // https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java#L175
183
+ readableArray!!.toArrayList()
184
+ }
185
+ }
@@ -0,0 +1,35 @@
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.WritableMap
21
+ import io.invertase.firebase.interfaces.NativeEvent
22
+
23
+ class ReactNativeFirebaseEvent
24
+ @JvmOverloads
25
+ constructor(
26
+ private val eventName: String,
27
+ private val eventBody: WritableMap,
28
+ private val firebaseAppName: String? = null,
29
+ ) : NativeEvent {
30
+ override fun getEventName(): String = eventName
31
+
32
+ override fun getEventBody(): WritableMap = eventBody
33
+
34
+ override fun getFirebaseAppName(): String? = firebaseAppName
35
+ }