@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.
- package/CHANGELOG.md +48 -0
- package/README.md +10 -27
- package/RNFBApp.podspec +13 -5
- package/android/build.gradle +3 -0
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.kt +29 -0
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.kt +146 -0
- package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.kt +156 -0
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.kt +44 -0
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.kt +100 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.kt +250 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.kt +64 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/{ReactNativeFirebaseAppInitProvider.java → ReactNativeFirebaseAppInitProvider.kt} +3 -4
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.kt +47 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.kt +33 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
- package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.kt +185 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.kt +35 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.kt +662 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.kt +103 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.kt +96 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.kt +140 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.kt +109 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.kt +451 -0
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{ContextProvider.java → ContextProvider.kt} +8 -8
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeError.java → NativeError.kt} +8 -8
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeEvent.java → NativeEvent.kt} +6 -6
- package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.kt +219 -0
- package/android/src/test/java/expo/core/ModuleRegistry.java +9 -0
- package/android/src/test/java/io/invertase/firebase/app/NativeRNFBTurboAppTest.java +182 -59
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppComponentsJavaCompatibilityTest.java +70 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppJavaCompatibilityTest.java +60 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackageTest.java +165 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppTest.kt +167 -0
- package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseJavaCompatibilityTest.java +112 -0
- package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseTest.kt +317 -0
- package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.kt +309 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterJavaCompatibilityTest.java +176 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterTest.java +143 -12
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventTest.kt +61 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONJavaCompatibilityTest.java +85 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.kt +296 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaJavaCompatibilityTest.java +67 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaTest.kt +246 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseModuleTest.kt +254 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesJavaCompatibilityTest.java +87 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesTest.kt +260 -0
- package/android/src/test/java/io/invertase/firebase/common/SharedUtilsJavaCompatibilityTest.java +255 -0
- package/android/src/test/java/io/invertase/firebase/common/SharedUtilsTest.kt +674 -0
- package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.kt +290 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebaseModuleJavaCompatibilityTest.java +178 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesJavaCompatibilityTest.java +99 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesTest.kt +217 -0
- package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleJavaCompatibilityTest.java +176 -0
- package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleKotlinCompatibilityTest.kt +52 -0
- package/android/src/test/java/io/invertase/firebase/interfaces/InterfacesJavaCompatibilityTest.java +144 -0
- package/android/src/test/java/io/invertase/firebase/interfaces/NativeEventTest.kt +56 -0
- package/android/src/test/java/io/invertase/firebase/utils/NativeRNFBTurboUtilsTest.java +517 -21
- package/dist/module/FirebaseApp.js +10 -0
- package/dist/module/FirebaseApp.js.map +1 -1
- package/dist/module/common/deeps.js +3 -0
- package/dist/module/common/deeps.js.map +1 -1
- package/dist/module/internal/FirebaseModule.js.map +1 -1
- package/dist/module/internal/RNFBNativeEventEmitter.js +12 -1
- package/dist/module/internal/RNFBNativeEventEmitter.js.map +1 -1
- package/dist/module/internal/SharedEventEmitter.js +3 -1
- package/dist/module/internal/SharedEventEmitter.js.map +1 -1
- package/dist/module/internal/index.js +1 -0
- package/dist/module/internal/index.js.map +1 -1
- package/dist/module/internal/registry/app.js +7 -1
- package/dist/module/internal/registry/app.js.map +1 -1
- package/dist/module/types/app.js.map +1 -1
- package/dist/module/types/internal.js +2 -0
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/FirebaseApp.d.ts +7 -0
- package/dist/typescript/lib/FirebaseApp.d.ts.map +1 -1
- package/dist/typescript/lib/common/deeps.d.ts.map +1 -1
- package/dist/typescript/lib/internal/FirebaseModule.d.ts +2 -3
- package/dist/typescript/lib/internal/FirebaseModule.d.ts.map +1 -1
- package/dist/typescript/lib/internal/NativeModules.d.ts +4 -1
- package/dist/typescript/lib/internal/NativeModules.d.ts.map +1 -1
- package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts +2 -2
- package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts.map +1 -1
- package/dist/typescript/lib/internal/SharedEventEmitter.d.ts +3 -3
- package/dist/typescript/lib/internal/SharedEventEmitter.d.ts.map +1 -1
- package/dist/typescript/lib/internal/index.d.ts +1 -0
- package/dist/typescript/lib/internal/index.d.ts.map +1 -1
- package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
- package/dist/typescript/lib/types/app.d.ts +10 -3
- package/dist/typescript/lib/types/app.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +12 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/firebase-schema.json +4 -0
- package/firebase_spm.rb +552 -96
- package/ios/RNFBApp/RCTConvert+FIRApp.h +2 -5
- package/ios/RNFBApp/RCTConvert+FIRApp.m +11 -6
- package/ios/RNFBApp/RCTConvert+FIROptions.h +2 -5
- package/ios/RNFBApp/RCTConvert+FIROptions.m +11 -10
- package/ios/RNFBApp/RCTConvertFIRApp.swift +86 -0
- package/ios/RNFBApp/RCTConvertFIROptions.swift +259 -0
- package/ios/RNFBApp/RNFBAppCustomAuthDomains.swift +63 -0
- package/ios/RNFBApp/RNFBAppInitializeOptionsMapper.swift +113 -0
- package/ios/RNFBApp/RNFBAppLogLevelMapper.swift +53 -0
- package/ios/RNFBApp/RNFBAppModule+CustomAuthDomain.m +35 -0
- package/ios/RNFBApp/RNFBAppModule.h +6 -2
- package/ios/RNFBApp/RNFBAppModule.mm +65 -228
- package/ios/RNFBApp/RNFBAppModuleFirebase.swift +439 -0
- package/ios/RNFBApp/RNFBAppModuleImplementation.h +68 -0
- package/ios/RNFBApp/RNFBAppModuleImplementation.m +195 -0
- package/ios/RNFBApp/RNFBHandleMap.m +27 -56
- package/ios/RNFBApp/RNFBHandleMapStorage.swift +90 -0
- package/ios/RNFBApp/RNFBInitializeAppArguments.swift +82 -0
- package/ios/RNFBApp/RNFBJSON.m +22 -38
- package/ios/RNFBApp/RNFBJSONImplementation.swift +71 -0
- package/ios/RNFBApp/RNFBMeta.m +24 -26
- package/ios/RNFBApp/RNFBMetaStorage.swift +76 -0
- package/ios/RNFBApp/RNFBNullSentinelDecoding.swift +135 -0
- package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +30 -3
- package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +28 -5
- package/ios/RNFBApp/RNFBPreferences.m +22 -20
- package/ios/RNFBApp/RNFBPreferencesStorage.swift +101 -0
- package/ios/RNFBApp/RNFBRCTEventEmitter.m +36 -93
- package/ios/RNFBApp/RNFBRCTEventEmitterCore.swift +161 -0
- package/ios/RNFBApp/RNFBSharedUtils.h +2 -5
- package/ios/RNFBApp/RNFBSharedUtils.m +109 -198
- package/ios/RNFBApp/RNFBSharedUtilsConfig.swift +72 -0
- package/ios/RNFBApp/RNFBSharedUtilsFIRApp.swift +271 -0
- package/ios/RNFBApp/RNFBSharedUtilsFormatting.swift +59 -0
- package/ios/RNFBApp/RNFBSharedUtilsPromiseRejection.swift +88 -0
- package/ios/RNFBApp/RNFBUtilsHelpers.swift +116 -0
- package/ios/RNFBApp/RNFBUtilsModule+Foundation.m +44 -0
- package/ios/RNFBApp/RNFBUtilsModule+PhotoAssets.m +47 -0
- package/ios/RNFBApp/RNFBUtilsModule.h +11 -1
- package/ios/RNFBApp/RNFBUtilsModule.mm +10 -85
- package/ios/RNFBApp/RNFBUtilsModuleImplementation.h +32 -0
- package/ios/RNFBApp/RNFBUtilsModuleImplementation.m +56 -0
- package/ios/RNFBApp/RNFBVersion.m +1 -1
- package/ios/RNFBApp.xcodeproj/project.pbxproj +100 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FIRApp.m +171 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FirebaseCore.h +78 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FIRInstallations.m +7 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FirebaseInstallations.h +8 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppModuleHostStub.m +55 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.h +89 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.mm +30 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.h +19 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.m +32 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridgeModule.h +19 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.h +28 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.m +23 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTEventEmitter.h +9 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTInvalidating.h +24 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTUtils.h +9 -0
- package/ios/RNFBAppUnitTests/HostStubs/module.modulemap +13 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIRAppFacadeTests.m +61 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIRAppTests.swift +73 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIROptionsFacadeTests.m +57 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIROptionsTests.swift +243 -0
- package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsFacadeTests.m +73 -0
- package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsTests.swift +70 -0
- package/ios/RNFBAppUnitTests/RNFBAppInitializeOptionsMapperTests.swift +190 -0
- package/ios/RNFBAppUnitTests/RNFBAppLogLevelFacadeTests.m +76 -0
- package/ios/RNFBAppUnitTests/RNFBAppLogLevelMapperTests.swift +59 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseFacadeTests.m +215 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseTests.swift +430 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleLifecycleTests.m +206 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleShellTests.mm +367 -0
- package/ios/RNFBAppUnitTests/RNFBAppUnitTests.xcodeproj/project.pbxproj +355 -2
- package/ios/RNFBAppUnitTests/RNFBFirebaseAppClientTests.swift +165 -0
- package/ios/RNFBAppUnitTests/RNFBHandleMapStorageTests.swift +121 -0
- package/ios/RNFBAppUnitTests/RNFBInitializeAppArgumentsTests.swift +256 -0
- package/ios/RNFBAppUnitTests/RNFBJSONImplementationTests.swift +126 -0
- package/ios/RNFBAppUnitTests/RNFBJSONTests.m +172 -0
- package/ios/RNFBAppUnitTests/RNFBMetaStorageTests.swift +106 -0
- package/ios/RNFBAppUnitTests/RNFBMetaTests.m +65 -0
- package/ios/RNFBAppUnitTests/RNFBNullSentinelDecodingTests.swift +286 -0
- package/ios/RNFBAppUnitTests/RNFBNullSentinelInterceptorTests.m +312 -0
- package/ios/RNFBAppUnitTests/RNFBPreferencesStorageTests.swift +105 -0
- package/ios/RNFBAppUnitTests/RNFBPreferencesTests.m +110 -0
- package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterCoreTests.swift +163 -0
- package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterFacadeTests.m +141 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigFacadeTests.m +100 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigTests.swift +234 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppFacadeTests.m +145 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppTests.swift +173 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingFacadeTests.m +38 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingTests.swift +82 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsNullSentinelTests.m +35 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionFacadeTests.m +107 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionTests.swift +133 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsHelpersTests.swift +144 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsModuleFacadeTests.m +72 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsModuleShellTests.mm +282 -0
- package/ios/RNFBFirebase/Package.swift +53 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebase/RNFBFirebase.swift +285 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/Public/.gitkeep +0 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/RNFBFirebaseBridge.m +169 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/include/RNFBFirebaseBridge.h +52 -0
- package/ios/RNFBFirebaseUnitTests/RNFBAppDynamicFacadeTests.swift +240 -0
- package/{android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.java → ios/RNFBFirebaseUnitTests/RNFBFirebaseClientImport.swift} +23 -14
- package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/project.pbxproj +588 -0
- package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBFirebaseUnitTests.xcscheme +83 -0
- package/ios_config.sh +50 -22
- package/lib/FirebaseApp.ts +10 -0
- package/lib/common/deeps.ts +3 -0
- package/lib/internal/FirebaseModule.ts +6 -3
- package/lib/internal/NativeModules.ts +4 -1
- package/lib/internal/RNFBNativeEventEmitter.ts +14 -5
- package/lib/internal/SharedEventEmitter.ts +5 -1
- package/lib/internal/index.ts +1 -0
- package/lib/internal/react-native-vendor-emitter.d.ts +11 -0
- package/lib/internal/registry/app.ts +7 -1
- package/lib/types/app.ts +10 -3
- package/lib/types/internal.ts +19 -0
- package/lib/version.ts +1 -1
- package/package.json +8 -8
- package/plugin/build/ios/appDelegate.js +2 -2
- package/plugin/build/ios/podfile.js +16 -16
- package/plugin/build/pluginConfig.d.ts +4 -2
- package/plugin/src/ios/appDelegate.ts +2 -2
- package/plugin/src/ios/podfile.ts +20 -23
- package/plugin/src/pluginConfig.ts +4 -2
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.java +0 -150
- package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +0 -148
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +0 -62
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +0 -91
- package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.java +0 -224
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +0 -46
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +0 -49
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +0 -35
- package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +0 -192
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +0 -53
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +0 -606
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +0 -109
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +0 -101
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +0 -146
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +0 -96
- package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +0 -441
- package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.java +0 -223
- package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.java +0 -275
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.java +0 -108
- package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.java +0 -97
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
18
|
+
import RNFBFirebase
|
|
19
|
+
#else
|
|
20
|
+
import FirebaseCore
|
|
21
|
+
#endif
|
|
22
|
+
import Foundation
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* FIRApp configure / lookup / allApps previously hard-wired in `RNFBAppModule.mm`.
|
|
26
|
+
*
|
|
27
|
+
* Production adapts live `FirebaseApp` class methods; unit tests inject a lifecycle double.
|
|
28
|
+
*/
|
|
29
|
+
@objc public protocol RNFBFIRAppLifecycle: AnyObject {
|
|
30
|
+
@objc(defaultApp)
|
|
31
|
+
func defaultApp() -> AnyObject?
|
|
32
|
+
|
|
33
|
+
@objc(appNamed:)
|
|
34
|
+
func appNamed(_ name: String) -> AnyObject?
|
|
35
|
+
|
|
36
|
+
@objc(allApps)
|
|
37
|
+
func allApps() -> [AnyHashable: Any]?
|
|
38
|
+
|
|
39
|
+
@objc(configureWithOptions:)
|
|
40
|
+
func configure(withOptions options: AnyObject)
|
|
41
|
+
|
|
42
|
+
@objc(configureWithName:options:)
|
|
43
|
+
func configure(withName name: String, options: AnyObject)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* FIRApp instance mutations previously inline in `RNFBAppModule.mm`
|
|
48
|
+
* (`dataCollectionDefaultEnabled`, `deleteApp:`).
|
|
49
|
+
*/
|
|
50
|
+
@objc public protocol RNFBFIRAppMutating: AnyObject {
|
|
51
|
+
@objc(setDataCollectionDefaultEnabled:)
|
|
52
|
+
func setDataCollectionDefaultEnabled(_ enabled: Bool)
|
|
53
|
+
|
|
54
|
+
@objc(deleteApp:)
|
|
55
|
+
func deleteApp(_ completion: @escaping (Bool) -> Void)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* FIRConfiguration logger previously hard-wired to
|
|
60
|
+
* `[[FIRConfiguration sharedInstance] setLoggerLevel:]`.
|
|
61
|
+
*/
|
|
62
|
+
@objc public protocol RNFBFIRLoggerConfiguring: AnyObject {
|
|
63
|
+
@objc(setLoggerLevel:)
|
|
64
|
+
func setLoggerLevel(_ level: Int)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Optional `+[FIRApp registerLibrary:withVersion:]` (FIRAppInternal) previously gated by
|
|
69
|
+
* `#if __has_include(<FirebaseCore/FIRAppInternal.h>)`.
|
|
70
|
+
*/
|
|
71
|
+
@objc public protocol RNFBFIRLibraryRegistering: AnyObject {
|
|
72
|
+
@objc(registerLibrary:withVersion:)
|
|
73
|
+
func registerLibrary(_ name: String, withVersion version: String)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Adapts live options creation for `RNFBFIROptionsCreating`.
|
|
78
|
+
* Ownership lives in `RNFBFIROptionsAllocation` (always `takeRetainedValue()`).
|
|
79
|
+
*/
|
|
80
|
+
@objc(RNFBAppModuleFIROptionsFactory)
|
|
81
|
+
final class RNFBAppModuleFIROptionsFactory: NSObject, RNFBFIROptionsCreating {
|
|
82
|
+
@objc static let shared = RNFBAppModuleFIROptionsFactory()
|
|
83
|
+
|
|
84
|
+
func create(googleAppID: String?, gcmSenderID: String?) -> RNFBFIROptionsConfiguring {
|
|
85
|
+
RNFBFIROptionsConfiguringAdapter(
|
|
86
|
+
RNFBFIROptionsAllocation.create(googleAppID: googleAppID, gcmSenderID: gcmSenderID)
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
92
|
+
/**
|
|
93
|
+
* Adapts `RNFBFirebaseAppClient` class methods for `RNFBAppModuleFirebase`.
|
|
94
|
+
*/
|
|
95
|
+
@objc(RNFBFIRAppLifecycleAdapter)
|
|
96
|
+
final class RNFBFIRAppLifecycleAdapter: NSObject, RNFBFIRAppLifecycle {
|
|
97
|
+
@objc static let shared = RNFBFIRAppLifecycleAdapter()
|
|
98
|
+
|
|
99
|
+
func defaultApp() -> AnyObject? {
|
|
100
|
+
RNFBFirebaseAppClient.defaultApp()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
func appNamed(_ name: String) -> AnyObject? {
|
|
104
|
+
RNFBFirebaseAppClient.app(named: name)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
func allApps() -> [AnyHashable: Any]? {
|
|
108
|
+
RNFBFirebaseAppClient.allApps()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
func configure(withOptions options: AnyObject) {
|
|
112
|
+
RNFBFirebaseAppClient.configure(options: options as! NSObject)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
func configure(withName name: String, options: AnyObject) {
|
|
116
|
+
RNFBFirebaseAppClient.configure(name: name, options: options as! NSObject)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Adapts logger level through the facade.
|
|
122
|
+
*/
|
|
123
|
+
@objc(RNFBFIRLoggerConfigurationAdapter)
|
|
124
|
+
final class RNFBFIRLoggerConfigurationAdapter: NSObject, RNFBFIRLoggerConfiguring {
|
|
125
|
+
@objc static let shared = RNFBFIRLoggerConfigurationAdapter()
|
|
126
|
+
|
|
127
|
+
func setLoggerLevel(_ level: Int) {
|
|
128
|
+
RNFBFirebaseAppClient.setLoggerLevel(level)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Adapts optional library registration through the facade.
|
|
134
|
+
*/
|
|
135
|
+
@objc(RNFBFIRLibraryRegisteringAdapter)
|
|
136
|
+
final class RNFBFIRLibraryRegisteringAdapter: NSObject, RNFBFIRLibraryRegistering {
|
|
137
|
+
@objc static let shared = RNFBFIRLibraryRegisteringAdapter()
|
|
138
|
+
|
|
139
|
+
func registerLibrary(_ name: String, withVersion version: String) {
|
|
140
|
+
RNFBFirebaseAppClient.registerLibrary(name: name, version: version)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
#else
|
|
144
|
+
/**
|
|
145
|
+
* Adapts live `FirebaseApp` (`FIRApp`) class methods for `RNFBAppModuleFirebase`.
|
|
146
|
+
*/
|
|
147
|
+
@objc(RNFBFIRAppLifecycleAdapter)
|
|
148
|
+
final class RNFBFIRAppLifecycleAdapter: NSObject, RNFBFIRAppLifecycle {
|
|
149
|
+
@objc static let shared = RNFBFIRAppLifecycleAdapter()
|
|
150
|
+
|
|
151
|
+
func defaultApp() -> AnyObject? {
|
|
152
|
+
FirebaseApp.app()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
func appNamed(_ name: String) -> AnyObject? {
|
|
156
|
+
FirebaseApp.app(name: name)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
func allApps() -> [AnyHashable: Any]? {
|
|
160
|
+
FirebaseApp.allApps
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
func configure(withOptions options: AnyObject) {
|
|
164
|
+
FirebaseApp.configure(options: options as! FirebaseOptions)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
func configure(withName name: String, options: AnyObject) {
|
|
168
|
+
FirebaseApp.configure(name: name, options: options as! FirebaseOptions)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Adapts a live `FirebaseApp` instance for data-collection / delete.
|
|
174
|
+
*/
|
|
175
|
+
@objc(RNFBFIRAppMutatingAdapter)
|
|
176
|
+
final class RNFBFIRAppMutatingAdapter: NSObject, RNFBFIRAppMutating {
|
|
177
|
+
private let app: FirebaseApp
|
|
178
|
+
|
|
179
|
+
init(app: FirebaseApp) {
|
|
180
|
+
self.app = app
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
func setDataCollectionDefaultEnabled(_ enabled: Bool) {
|
|
184
|
+
app.isDataCollectionDefaultEnabled = enabled
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
func deleteApp(_ completion: @escaping (Bool) -> Void) {
|
|
188
|
+
app.delete { success in
|
|
189
|
+
completion(success)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Adapts live `FirebaseConfiguration` (`FIRConfiguration`) for logger level.
|
|
196
|
+
*/
|
|
197
|
+
@objc(RNFBFIRLoggerConfigurationAdapter)
|
|
198
|
+
final class RNFBFIRLoggerConfigurationAdapter: NSObject, RNFBFIRLoggerConfiguring {
|
|
199
|
+
@objc static let shared = RNFBFIRLoggerConfigurationAdapter()
|
|
200
|
+
|
|
201
|
+
func setLoggerLevel(_ level: Int) {
|
|
202
|
+
// Pre-port used an unchecked `(FIRLoggerLevel)level` cast. Unknown raw values
|
|
203
|
+
// must pass through rather than falling back to `.error`.
|
|
204
|
+
let loggerLevel = unsafeBitCast(level, to: FirebaseLoggerLevel.self)
|
|
205
|
+
FirebaseConfiguration.shared.setLoggerLevel(loggerLevel)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Adapts optional `+[FIRApp registerLibrary:withVersion:]` when the selector exists
|
|
211
|
+
* (same availability gate as pre-port `FIRAppInternal.h` / `REGISTER_LIB`).
|
|
212
|
+
*/
|
|
213
|
+
@objc(RNFBFIRLibraryRegisteringAdapter)
|
|
214
|
+
final class RNFBFIRLibraryRegisteringAdapter: NSObject, RNFBFIRLibraryRegistering {
|
|
215
|
+
@objc static let shared = RNFBFIRLibraryRegisteringAdapter()
|
|
216
|
+
|
|
217
|
+
private static let registerSelector = NSSelectorFromString("registerLibrary:withVersion:")
|
|
218
|
+
|
|
219
|
+
static func registerLibrary(_ name: String, version: String, on target: NSObject.Type) {
|
|
220
|
+
guard target.responds(to: registerSelector) else { return }
|
|
221
|
+
target.perform(registerSelector, with: name, with: version)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
func registerLibrary(_ name: String, withVersion version: String) {
|
|
225
|
+
Self.registerLibrary(name, version: version, on: FirebaseApp.self)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
#endif
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* FIRApp / FIROptions / FIRConfiguration helpers previously inline in `RNFBAppModule.mm`.
|
|
232
|
+
*
|
|
233
|
+
* Mirrors pre-port:
|
|
234
|
+
* - default-app initialize reuses an already-configured default app
|
|
235
|
+
* - named apps use `configureWithName:options:`
|
|
236
|
+
* - `allApps` feeds `NATIVE_FIREBASE_APPS`
|
|
237
|
+
* - `registerLibrary` runs once when the internal selector exists
|
|
238
|
+
* - deleteApp completion + caller-owned retry
|
|
239
|
+
*/
|
|
240
|
+
@objc(RNFBAppModuleFirebase)
|
|
241
|
+
public final class RNFBAppModuleFirebase: NSObject {
|
|
242
|
+
private static let registerLock = NSLock()
|
|
243
|
+
private static var didRegisterLibrary = false
|
|
244
|
+
|
|
245
|
+
@objc(optionsFactory)
|
|
246
|
+
public static func optionsFactory() -> RNFBFIROptionsCreating {
|
|
247
|
+
RNFBAppModuleFIROptionsFactory.shared
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@objc(registerLibraryOnceWithName:version:)
|
|
251
|
+
public static func registerLibraryOnce(name: String, version: String) {
|
|
252
|
+
registerLibraryOnce(
|
|
253
|
+
name: name,
|
|
254
|
+
version: version,
|
|
255
|
+
registrar: RNFBFIRLibraryRegisteringAdapter.shared
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@objc(registerLibraryOnceWithName:version:registrar:)
|
|
260
|
+
public static func registerLibraryOnce(
|
|
261
|
+
name: String,
|
|
262
|
+
version: String,
|
|
263
|
+
registrar: RNFBFIRLibraryRegistering
|
|
264
|
+
) {
|
|
265
|
+
registerLock.lock()
|
|
266
|
+
defer { registerLock.unlock() }
|
|
267
|
+
guard !didRegisterLibrary else { return }
|
|
268
|
+
didRegisterLibrary = true
|
|
269
|
+
registrar.registerLibrary(name, withVersion: version)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/// Clears the once-token. Unit-test / HostStub seam only.
|
|
273
|
+
@objc(resetRegisterLibraryOnceForTesting)
|
|
274
|
+
public static func resetRegisterLibraryOnceForTesting() {
|
|
275
|
+
registerLock.lock()
|
|
276
|
+
defer { registerLock.unlock() }
|
|
277
|
+
didRegisterLibrary = false
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@objc(allApps)
|
|
281
|
+
public static func allApps() -> [AnyObject] {
|
|
282
|
+
allApps(lifecycle: RNFBFIRAppLifecycleAdapter.shared)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@objc(allAppsWithLifecycle:)
|
|
286
|
+
public static func allApps(lifecycle: RNFBFIRAppLifecycle) -> [AnyObject] {
|
|
287
|
+
guard let apps = lifecycle.allApps() else { return [] }
|
|
288
|
+
return Array(apps.values).compactMap { $0 as AnyObject }
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@objc(appForName:)
|
|
292
|
+
public static func app(forName appName: String) -> AnyObject? {
|
|
293
|
+
RCTConvertFIRApp.firApp(fromString: appName)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@objc(configureOrReuseAppWithOptions:nameResolution:)
|
|
297
|
+
public static func configureOrReuseApp(
|
|
298
|
+
options: RNFBFIROptionsConfiguring,
|
|
299
|
+
nameResolution: RNFBAppInitializeNameResolution
|
|
300
|
+
) -> AnyObject? {
|
|
301
|
+
configureOrReuseApp(
|
|
302
|
+
options: options,
|
|
303
|
+
nameResolution: nameResolution,
|
|
304
|
+
lifecycle: RNFBFIRAppLifecycleAdapter.shared
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
@objc(configureOrReuseAppWithOptions:nameResolution:lifecycle:)
|
|
309
|
+
public static func configureOrReuseApp(
|
|
310
|
+
options: RNFBFIROptionsConfiguring,
|
|
311
|
+
nameResolution: RNFBAppInitializeNameResolution,
|
|
312
|
+
lifecycle: RNFBFIRAppLifecycle
|
|
313
|
+
) -> AnyObject? {
|
|
314
|
+
// Pre-port read the app back with `[FIRApp defaultApp]` / `appNamed:` and passed the
|
|
315
|
+
// result on unchecked, so a nil lookup flowed to the caller rather than trapping.
|
|
316
|
+
// Production factories wrap live `FirebaseOptions` in
|
|
317
|
+
// `RNFBFIROptionsConfiguringAdapter`. Configure needs the underlying SDK object.
|
|
318
|
+
let firOptions: AnyObject
|
|
319
|
+
if let adapter = options as? RNFBFIROptionsConfiguringAdapter {
|
|
320
|
+
firOptions = adapter.options
|
|
321
|
+
} else {
|
|
322
|
+
firOptions = options
|
|
323
|
+
}
|
|
324
|
+
if nameResolution.isDefaultApp {
|
|
325
|
+
if let existing = lifecycle.defaultApp() {
|
|
326
|
+
return existing
|
|
327
|
+
}
|
|
328
|
+
lifecycle.configure(withOptions: firOptions)
|
|
329
|
+
return lifecycle.defaultApp()
|
|
330
|
+
}
|
|
331
|
+
let appName = nameResolution.appName ?? ""
|
|
332
|
+
lifecycle.configure(withName: appName, options: firOptions)
|
|
333
|
+
return lifecycle.appNamed(appName)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@objc(setLoggerLevel:)
|
|
337
|
+
public static func setLoggerLevel(_ level: Int) {
|
|
338
|
+
setLoggerLevel(level, configuration: RNFBFIRLoggerConfigurationAdapter.shared)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
@objc(setLoggerLevel:configuration:)
|
|
342
|
+
public static func setLoggerLevel(_ level: Int, configuration: RNFBFIRLoggerConfiguring) {
|
|
343
|
+
configuration.setLoggerLevel(level)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
@objc(setAutomaticDataCollectionEnabled:forAppName:)
|
|
347
|
+
public static func setAutomaticDataCollectionEnabled(_ enabled: Bool, forAppName appName: String) {
|
|
348
|
+
guard let app = app(forName: appName) else { return }
|
|
349
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
350
|
+
_ = RNFBFirebaseAppClient.setDataCollectionDefaultEnabled(enabled, forApp: app as! NSObject)
|
|
351
|
+
#else
|
|
352
|
+
guard let firebaseApp = app as? FirebaseApp else { return }
|
|
353
|
+
RNFBFIRAppMutatingAdapter(app: firebaseApp).setDataCollectionDefaultEnabled(enabled)
|
|
354
|
+
#endif
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@objc(setDataCollectionDefaultEnabled:forApp:)
|
|
358
|
+
public static func setDataCollectionDefaultEnabled(_ enabled: Bool, forApp app: AnyObject) {
|
|
359
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
360
|
+
_ = RNFBFirebaseAppClient.setDataCollectionDefaultEnabled(enabled, forApp: app as! NSObject)
|
|
361
|
+
#else
|
|
362
|
+
guard let firebaseApp = app as? FirebaseApp else { return }
|
|
363
|
+
RNFBFIRAppMutatingAdapter(app: firebaseApp).setDataCollectionDefaultEnabled(enabled)
|
|
364
|
+
#endif
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
@objc(deleteApp:completion:)
|
|
368
|
+
public static func deleteApp(_ app: AnyObject, completion: @escaping (Bool) -> Void) {
|
|
369
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
370
|
+
if !RNFBFirebaseAppClient.deleteApp(app as! NSObject, completion: completion) {
|
|
371
|
+
completion(false)
|
|
372
|
+
}
|
|
373
|
+
#else
|
|
374
|
+
guard let firebaseApp = app as? FirebaseApp else {
|
|
375
|
+
completion(false)
|
|
376
|
+
return
|
|
377
|
+
}
|
|
378
|
+
RNFBFIRAppMutatingAdapter(app: firebaseApp).deleteApp(completion)
|
|
379
|
+
#endif
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
@objc(deleteApp:mutating:completion:)
|
|
383
|
+
public static func deleteApp(
|
|
384
|
+
_ app: AnyObject,
|
|
385
|
+
mutating: RNFBFIRAppMutating,
|
|
386
|
+
completion: @escaping (Bool) -> Void
|
|
387
|
+
) {
|
|
388
|
+
_ = app
|
|
389
|
+
mutating.deleteApp(completion)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/// Native `deleteApp` with missing-app resolve-null and retry-once reject.
|
|
393
|
+
@objc(deleteAppNamed:resolve:reject:)
|
|
394
|
+
public static func deleteApp(
|
|
395
|
+
named appName: String,
|
|
396
|
+
resolve: @escaping (Any?) -> Void,
|
|
397
|
+
reject: @escaping (String, String, Error?) -> Void
|
|
398
|
+
) {
|
|
399
|
+
deleteApp(
|
|
400
|
+
named: appName,
|
|
401
|
+
resolve: resolve,
|
|
402
|
+
reject: reject,
|
|
403
|
+
appLookup: { app(forName: $0) },
|
|
404
|
+
performDelete: { candidate, completion in
|
|
405
|
+
deleteApp(candidate, completion: completion)
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/// Testable delete orchestration (lookup + retry-once).
|
|
411
|
+
public static func deleteApp(
|
|
412
|
+
named appName: String,
|
|
413
|
+
resolve: @escaping (Any?) -> Void,
|
|
414
|
+
reject: @escaping (String, String, Error?) -> Void,
|
|
415
|
+
appLookup: (String) -> AnyObject?,
|
|
416
|
+
performDelete: @escaping (AnyObject, @escaping (Bool) -> Void) -> Void
|
|
417
|
+
) {
|
|
418
|
+
guard let firApp = appLookup(appName) else {
|
|
419
|
+
resolve(NSNull())
|
|
420
|
+
return
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
performDelete(firApp) { success in
|
|
424
|
+
if success {
|
|
425
|
+
RNFBAppCustomAuthDomains.setCustomDomain(nil, forAppName: appName)
|
|
426
|
+
resolve(NSNull())
|
|
427
|
+
} else {
|
|
428
|
+
performDelete(firApp) { success2 in
|
|
429
|
+
if success2 {
|
|
430
|
+
RNFBAppCustomAuthDomains.setCustomDomain(nil, forAppName: appName)
|
|
431
|
+
resolve(NSNull())
|
|
432
|
+
} else {
|
|
433
|
+
reject("app/delete-app-failed", "Failed to delete the specified app.", nil)
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#import <Foundation/Foundation.h>
|
|
18
|
+
#import <React/RCTBridgeModule.h>
|
|
19
|
+
|
|
20
|
+
@class RCTBridge;
|
|
21
|
+
|
|
22
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
23
|
+
|
|
24
|
+
FOUNDATION_EXPORT void RNFBAppModuleInitialize(void);
|
|
25
|
+
FOUNDATION_EXPORT void RNFBAppModuleSetBridge(RCTBridge *bridge);
|
|
26
|
+
FOUNDATION_EXPORT RCTBridge *RNFBAppModuleBridge(void);
|
|
27
|
+
FOUNDATION_EXPORT void RNFBAppModuleInvalidate(void);
|
|
28
|
+
FOUNDATION_EXPORT NSDictionary *RNFBAppModuleConstantsDictionary(void);
|
|
29
|
+
|
|
30
|
+
FOUNDATION_EXPORT void RNFBAppModuleInitializeApp(NSDictionary *options, NSDictionary *appConfig,
|
|
31
|
+
RCTPromiseResolveBlock resolve,
|
|
32
|
+
RCTPromiseRejectBlock reject);
|
|
33
|
+
FOUNDATION_EXPORT void RNFBAppModuleCompleteInitializeApp(id _Nullable firApp,
|
|
34
|
+
NSString *_Nullable authDomain,
|
|
35
|
+
NSString *jsAppName,
|
|
36
|
+
NSDictionary *appConfig,
|
|
37
|
+
RCTPromiseResolveBlock resolve);
|
|
38
|
+
FOUNDATION_EXPORT void RNFBAppModuleSetAutomaticDataCollectionEnabled(NSString *appName,
|
|
39
|
+
BOOL enabled);
|
|
40
|
+
FOUNDATION_EXPORT void RNFBAppModuleDeleteApp(NSString *appName, RCTPromiseResolveBlock resolve,
|
|
41
|
+
RCTPromiseRejectBlock reject);
|
|
42
|
+
FOUNDATION_EXPORT void RNFBAppModuleEventsNotifyReady(BOOL ready);
|
|
43
|
+
FOUNDATION_EXPORT void RNFBAppModuleEventsGetListeners(RCTPromiseResolveBlock resolve,
|
|
44
|
+
RCTPromiseRejectBlock reject);
|
|
45
|
+
FOUNDATION_EXPORT void RNFBAppModuleEventsPing(NSString *eventName, NSDictionary *eventBody,
|
|
46
|
+
RCTPromiseResolveBlock resolve,
|
|
47
|
+
RCTPromiseRejectBlock reject);
|
|
48
|
+
FOUNDATION_EXPORT void RNFBAppModuleEventsAddListener(NSString *eventName);
|
|
49
|
+
FOUNDATION_EXPORT void RNFBAppModuleEventsRemoveListener(NSString *eventName, BOOL all);
|
|
50
|
+
FOUNDATION_EXPORT void RNFBAppModuleAddListener(NSString *eventName);
|
|
51
|
+
FOUNDATION_EXPORT void RNFBAppModuleRemoveListeners(double count);
|
|
52
|
+
FOUNDATION_EXPORT void RNFBAppModuleMetaGetAll(RCTPromiseResolveBlock resolve,
|
|
53
|
+
RCTPromiseRejectBlock reject);
|
|
54
|
+
FOUNDATION_EXPORT void RNFBAppModuleJSONGetAll(RCTPromiseResolveBlock resolve,
|
|
55
|
+
RCTPromiseRejectBlock reject);
|
|
56
|
+
FOUNDATION_EXPORT void RNFBAppModulePreferencesSetBool(NSString *key, BOOL value,
|
|
57
|
+
RCTPromiseResolveBlock resolve,
|
|
58
|
+
RCTPromiseRejectBlock reject);
|
|
59
|
+
FOUNDATION_EXPORT void RNFBAppModulePreferencesSetString(NSString *key, NSString *value,
|
|
60
|
+
RCTPromiseResolveBlock resolve,
|
|
61
|
+
RCTPromiseRejectBlock reject);
|
|
62
|
+
FOUNDATION_EXPORT void RNFBAppModulePreferencesGetAll(RCTPromiseResolveBlock resolve,
|
|
63
|
+
RCTPromiseRejectBlock reject);
|
|
64
|
+
FOUNDATION_EXPORT void RNFBAppModulePreferencesClearAll(RCTPromiseResolveBlock resolve,
|
|
65
|
+
RCTPromiseRejectBlock reject);
|
|
66
|
+
FOUNDATION_EXPORT void RNFBAppModuleSetLogLevel(NSString *logLevel);
|
|
67
|
+
|
|
68
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#import <React/RCTUtils.h>
|
|
18
|
+
|
|
19
|
+
#import "RNFBAppModuleImplementation.h"
|
|
20
|
+
#import "RNFBJSON.h"
|
|
21
|
+
#import "RNFBMeta.h"
|
|
22
|
+
#import "RNFBPreferences.h"
|
|
23
|
+
#import "RNFBRCTEventEmitter.h"
|
|
24
|
+
#import "RNFBSharedUtils.h"
|
|
25
|
+
#import "RNFBVersion.h"
|
|
26
|
+
|
|
27
|
+
#if __has_include(<RNFBApp/RNFBApp-Swift.h>)
|
|
28
|
+
#import <RNFBApp/RNFBApp-Swift.h>
|
|
29
|
+
#elif __has_include("RNFBApp-Swift.h")
|
|
30
|
+
#import "RNFBApp-Swift.h"
|
|
31
|
+
#elif __has_include("RNFBHandleMapStorage-Swift.inc")
|
|
32
|
+
#import "RNFBHandleMapStorage-Swift.inc"
|
|
33
|
+
#else
|
|
34
|
+
#error "RNFBApp Swift interface not found"
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
void RNFBAppModuleInitialize(void) {
|
|
38
|
+
[RNFBAppModuleFirebase registerLibraryOnceWithName:@"react-native-firebase"
|
|
39
|
+
version:[RNFBVersionString copy]];
|
|
40
|
+
if ([[RNFBJSON shared] contains:@"app_log_level"]) {
|
|
41
|
+
NSString *logLevel = [[RNFBJSON shared] getStringValue:@"app_log_level" defaultValue:@"info"];
|
|
42
|
+
RNFBAppModuleSetLogLevel(logLevel);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void RNFBAppModuleSetBridge(RCTBridge *bridge) { [RNFBRCTEventEmitter shared].bridge = bridge; }
|
|
47
|
+
|
|
48
|
+
RCTBridge *RNFBAppModuleBridge(void) { return [RNFBRCTEventEmitter shared].bridge; }
|
|
49
|
+
|
|
50
|
+
void RNFBAppModuleInvalidate(void) { [[RNFBRCTEventEmitter shared] invalidate]; }
|
|
51
|
+
|
|
52
|
+
NSDictionary *RNFBAppModuleConstantsDictionary(void) {
|
|
53
|
+
NSArray *firApps = [RNFBAppModuleFirebase allApps];
|
|
54
|
+
NSMutableArray *appsArray = [NSMutableArray new];
|
|
55
|
+
NSMutableDictionary *constants = [NSMutableDictionary new];
|
|
56
|
+
|
|
57
|
+
for (id firApp in firApps) {
|
|
58
|
+
[appsArray addObject:[RNFBSharedUtils firAppToDictionary:firApp]];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
constants[@"NATIVE_FIREBASE_APPS"] = appsArray;
|
|
62
|
+
constants[@"FIREBASE_RAW_JSON"] = [[RNFBJSON shared] getRawJSON];
|
|
63
|
+
return constants;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void RNFBAppModuleMetaGetAll(RCTPromiseResolveBlock resolve, RCTPromiseRejectBlock reject) {
|
|
67
|
+
resolve([RNFBMeta getAll]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void RNFBAppModuleJSONGetAll(RCTPromiseResolveBlock resolve, RCTPromiseRejectBlock reject) {
|
|
71
|
+
resolve([[RNFBJSON shared] getAll]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
void RNFBAppModulePreferencesSetBool(NSString *key, BOOL value, RCTPromiseResolveBlock resolve,
|
|
75
|
+
RCTPromiseRejectBlock reject) {
|
|
76
|
+
[[RNFBPreferences shared] setBooleanValue:key boolValue:value];
|
|
77
|
+
resolve([NSNull null]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void RNFBAppModulePreferencesSetString(NSString *key, NSString *value,
|
|
81
|
+
RCTPromiseResolveBlock resolve,
|
|
82
|
+
RCTPromiseRejectBlock reject) {
|
|
83
|
+
[[RNFBPreferences shared] setStringValue:key stringValue:value];
|
|
84
|
+
resolve([NSNull null]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void RNFBAppModulePreferencesGetAll(RCTPromiseResolveBlock resolve, RCTPromiseRejectBlock reject) {
|
|
88
|
+
resolve([[RNFBPreferences shared] getAll]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void RNFBAppModulePreferencesClearAll(RCTPromiseResolveBlock resolve,
|
|
92
|
+
RCTPromiseRejectBlock reject) {
|
|
93
|
+
[[RNFBPreferences shared] clearAll];
|
|
94
|
+
resolve([NSNull null]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void RNFBAppModuleEventsNotifyReady(BOOL ready) {
|
|
98
|
+
[[RNFBRCTEventEmitter shared] notifyJsReady:ready];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void RNFBAppModuleEventsGetListeners(RCTPromiseResolveBlock resolve, RCTPromiseRejectBlock reject) {
|
|
102
|
+
resolve([[RNFBRCTEventEmitter shared] getListenersDictionary]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void RNFBAppModuleEventsPing(NSString *eventName, NSDictionary *eventBody,
|
|
106
|
+
RCTPromiseResolveBlock resolve, RCTPromiseRejectBlock reject) {
|
|
107
|
+
[[RNFBRCTEventEmitter shared] sendEventWithName:eventName body:eventBody];
|
|
108
|
+
resolve(eventBody);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void RNFBAppModuleEventsAddListener(NSString *eventName) {
|
|
112
|
+
[[RNFBRCTEventEmitter shared] addListener:eventName];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
void RNFBAppModuleEventsRemoveListener(NSString *eventName, BOOL all) {
|
|
116
|
+
[[RNFBRCTEventEmitter shared] removeListeners:eventName all:all];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
void RNFBAppModuleAddListener(NSString *eventName) { (void)eventName; }
|
|
120
|
+
|
|
121
|
+
void RNFBAppModuleRemoveListeners(double count) { (void)count; }
|
|
122
|
+
|
|
123
|
+
void RNFBAppModuleInitializeApp(NSDictionary *options, NSDictionary *appConfig,
|
|
124
|
+
RCTPromiseResolveBlock resolve, RCTPromiseRejectBlock reject) {
|
|
125
|
+
// New Architecture delivers these as plain NSDictionary (no RCTCxxConvert), so JS null
|
|
126
|
+
// properties are still {__rnfbNull: true} sentinels. Null optional keys are dropped so they
|
|
127
|
+
// read as absent; a null automaticDataCollectionEnabled becomes @NO.
|
|
128
|
+
// Coalesce nil (root sentinel / missing args) so Swift mappers always receive a dictionary.
|
|
129
|
+
NSDictionary *normalizedOptions = [RNFBInitializeAppArguments normalizedOptions:options] ?: @{};
|
|
130
|
+
NSDictionary *normalizedAppConfig =
|
|
131
|
+
[RNFBInitializeAppArguments normalizedAppConfig:appConfig] ?: @{};
|
|
132
|
+
RCTUnsafeExecuteOnMainQueueSync(^{
|
|
133
|
+
id firApp;
|
|
134
|
+
RNFBAppInitializeNameResolution *names =
|
|
135
|
+
[RNFBAppInitializeOptionsMapper resolveNameFromAppConfig:normalizedAppConfig];
|
|
136
|
+
NSString *authDomain = [RNFBAppInitializeOptionsMapper authDomainFromOptions:normalizedOptions];
|
|
137
|
+
id firOptions =
|
|
138
|
+
[RNFBAppInitializeOptionsMapper buildOptionsFrom:normalizedOptions
|
|
139
|
+
optionsFactory:[RNFBAppModuleFirebase optionsFactory]];
|
|
140
|
+
|
|
141
|
+
// The catch only records the exception. A `return` inside it makes clang attribute zero
|
|
142
|
+
// hits to everything after the try, which hides the success path from coverage.
|
|
143
|
+
NSException *raised = nil;
|
|
144
|
+
@try {
|
|
145
|
+
firApp = [RNFBAppModuleFirebase configureOrReuseAppWithOptions:firOptions
|
|
146
|
+
nameResolution:names];
|
|
147
|
+
} @catch (NSException *exception) {
|
|
148
|
+
raised = exception;
|
|
149
|
+
}
|
|
150
|
+
if (raised != nil) {
|
|
151
|
+
[RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:raised];
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
RNFBAppModuleCompleteInitializeApp(firApp, authDomain, names.jsAppName, normalizedAppConfig,
|
|
156
|
+
resolve);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
void RNFBAppModuleCompleteInitializeApp(id firApp, NSString *authDomain, NSString *jsAppName,
|
|
161
|
+
NSDictionary *appConfig, RCTPromiseResolveBlock resolve) {
|
|
162
|
+
[RNFBAppCustomAuthDomains setCustomDomain:authDomain forAppName:jsAppName];
|
|
163
|
+
if (firApp == nil) {
|
|
164
|
+
// Pre-port messaged a nil app (no-ops) and mapped it to empty option/config sections.
|
|
165
|
+
resolve(@{@"options" : @{}, @"appConfig" : @{@"automaticDataCollectionEnabled" : @NO}});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Only apply when provided, so an omitted key keeps the SDK / Info.plist default (as Android).
|
|
170
|
+
// Pass normalizedAppConfig so a null sentinel has already become @NO. Pinned by
|
|
171
|
+
// RNFBInitializeAppArgumentsTests + RNFBAppModuleLifecycleTests.
|
|
172
|
+
NSNumber *automaticDataCollectionEnabled =
|
|
173
|
+
[RNFBInitializeAppArguments automaticDataCollectionEnabledFromAppConfig:appConfig];
|
|
174
|
+
if (automaticDataCollectionEnabled != nil) {
|
|
175
|
+
[RNFBAppModuleFirebase
|
|
176
|
+
setDataCollectionDefaultEnabled:[automaticDataCollectionEnabled boolValue]
|
|
177
|
+
forApp:firApp];
|
|
178
|
+
}
|
|
179
|
+
resolve([RNFBSharedUtils firAppToDictionary:firApp]);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void RNFBAppModuleSetAutomaticDataCollectionEnabled(NSString *appName, BOOL enabled) {
|
|
183
|
+
[RNFBAppModuleFirebase setAutomaticDataCollectionEnabled:enabled forAppName:appName];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void RNFBAppModuleDeleteApp(NSString *appName, RCTPromiseResolveBlock resolve,
|
|
187
|
+
RCTPromiseRejectBlock reject) {
|
|
188
|
+
[RNFBAppModuleFirebase deleteAppNamed:appName resolve:resolve reject:reject];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void RNFBAppModuleSetLogLevel(NSString *logLevel) {
|
|
192
|
+
int level = (int)[RNFBAppLogLevelMapper loggerLevelForString:logLevel];
|
|
193
|
+
DLog(@"RNFBSetLogLevel: setting level to %d from %@.", level, logLevel);
|
|
194
|
+
[RNFBAppModuleFirebase setLoggerLevel:level];
|
|
195
|
+
}
|