@react-native-firebase/app 26.3.3 → 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 +75 -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 +208 -60
- 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 +144 -13
- 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 -23
- package/dist/module/FirebaseApp.js +10 -0
- package/dist/module/FirebaseApp.js.map +1 -1
- package/dist/module/common/Base64.js +13 -21
- package/dist/module/common/Base64.js.map +1 -1
- package/dist/module/common/deeps.js +3 -0
- package/dist/module/common/deeps.js.map +1 -1
- package/dist/module/common/index.js +17 -9
- package/dist/module/common/index.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/asyncStorage.js +7 -11
- package/dist/module/internal/asyncStorage.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/logger.js +44 -40
- package/dist/module/internal/logger.js.map +1 -1
- package/dist/module/internal/nativeModuleAndroidIos.js +2 -29
- package/dist/module/internal/nativeModuleAndroidIos.js.map +1 -1
- package/dist/module/internal/nativeModuleDebug.js +74 -0
- package/dist/module/internal/nativeModuleDebug.js.map +1 -0
- package/dist/module/internal/nativeModuleWeb.js +9 -29
- package/dist/module/internal/nativeModuleWeb.js.map +1 -1
- package/dist/module/internal/registry/app.js +8 -2
- package/dist/module/internal/registry/app.js.map +1 -1
- package/dist/module/internal/registry/modular.js +2 -2
- package/dist/module/internal/registry/modular.js.map +1 -1
- package/dist/module/internal/registry/nativeModule.js +3 -3
- package/dist/module/internal/registry/nativeModule.js.map +1 -1
- package/dist/module/internal/web/RNFBAppModule.js +16 -15
- package/dist/module/internal/web/RNFBAppModule.js.map +1 -1
- package/dist/module/internal/web/memidb/lib/FakeEventTarget.js +3 -1
- package/dist/module/internal/web/memidb/lib/FakeEventTarget.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/Base64.d.ts.map +1 -1
- package/dist/typescript/lib/common/deeps.d.ts.map +1 -1
- package/dist/typescript/lib/common/index.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/asyncStorage.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/logger.d.ts.map +1 -1
- package/dist/typescript/lib/internal/nativeModuleAndroidIos.d.ts.map +1 -1
- package/dist/typescript/lib/internal/nativeModuleDebug.d.ts +2 -0
- package/dist/typescript/lib/internal/nativeModuleDebug.d.ts.map +1 -0
- package/dist/typescript/lib/internal/nativeModuleWeb.d.ts.map +1 -1
- package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
- package/dist/typescript/lib/internal/web/RNFBAppModule.d.ts +7 -7
- package/dist/typescript/lib/internal/web/RNFBAppModule.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 +5 -1
- 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 +67 -204
- 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.h +73 -0
- package/ios/RNFBApp/RNFBHandleMap.m +87 -0
- 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 -197
- 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 +106 -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 +590 -0
- package/ios/RNFBAppUnitTests/RNFBAppUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBAppUnitTests.xcscheme +69 -0
- package/ios/RNFBAppUnitTests/RNFBFirebaseAppClientTests.swift +165 -0
- package/ios/RNFBAppUnitTests/RNFBHandleMapStorageTests.swift +121 -0
- package/ios/RNFBAppUnitTests/RNFBHandleMapTests.m +238 -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/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java → ios/RNFBFirebaseUnitTests/RNFBFirebaseClientImport.swift} +22 -17
- 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/Base64.ts +10 -16
- package/lib/common/deeps.ts +3 -0
- package/lib/common/index.ts +20 -9
- 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/asyncStorage.ts +7 -11
- package/lib/internal/index.ts +1 -0
- package/lib/internal/logger.ts +53 -43
- package/lib/internal/nativeModuleAndroidIos.ts +2 -40
- package/lib/internal/nativeModuleDebug.ts +97 -0
- package/lib/internal/nativeModuleWeb.ts +10 -40
- package/lib/internal/react-native-vendor-emitter.d.ts +11 -0
- package/lib/internal/registry/app.ts +8 -2
- package/lib/internal/registry/modular.ts +2 -2
- package/lib/internal/registry/nativeModule.ts +3 -3
- package/lib/internal/web/RNFBAppModule.ts +16 -15
- package/lib/internal/web/memidb/lib/FakeEventTarget.js +3 -1
- package/lib/types/app.ts +10 -3
- package/lib/types/internal.ts +19 -0
- package/lib/version.ts +1 -1
- package/package.json +9 -8
- package/plugin/build/ios/appDelegate.js +19 -9
- package/plugin/build/ios/podfile.js +16 -16
- package/plugin/build/pluginConfig.d.ts +4 -2
- package/plugin/src/ios/appDelegate.ts +45 -15
- package/plugin/src/ios/podfile.ts +20 -23
- package/plugin/src/pluginConfig.ts +4 -2
- package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +0 -124
- 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 -222
- 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/common/RCTConvertFirebase.java +0 -191
- 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 -107
- 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
|
@@ -0,0 +1,206 @@
|
|
|
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 <XCTest/XCTest.h>
|
|
18
|
+
|
|
19
|
+
#import <React/RCTBridge.h>
|
|
20
|
+
#import "FirebaseCore/FirebaseCore.h"
|
|
21
|
+
#import "RNFBAppModule.h"
|
|
22
|
+
#import "RNFBAppModuleImplementation.h"
|
|
23
|
+
#import "RNFBHandleMapStorage-Swift.inc"
|
|
24
|
+
#import "RNFBJSON.h"
|
|
25
|
+
#import "RNFBRCTEventEmitter.h"
|
|
26
|
+
|
|
27
|
+
@interface RNFBAppModuleLifecycleTests : XCTestCase
|
|
28
|
+
@property(nonatomic, strong) RNFBAppModule *module;
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@implementation RNFBAppModuleLifecycleTests
|
|
32
|
+
|
|
33
|
+
- (void)setUp {
|
|
34
|
+
[super setUp];
|
|
35
|
+
self.module = [[RNFBAppModule alloc] init];
|
|
36
|
+
[[RNFBRCTEventEmitter shared] invalidate];
|
|
37
|
+
[RNFBRCTEventEmitter shared].bridge = nil;
|
|
38
|
+
[FIRApp resetRegistryForTesting];
|
|
39
|
+
[RNFBAppCustomAuthDomains resetCustomDomainsForTesting];
|
|
40
|
+
[FIRConfiguration resetForTesting];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)tearDown {
|
|
44
|
+
[[RNFBRCTEventEmitter shared] invalidate];
|
|
45
|
+
[RNFBRCTEventEmitter shared].bridge = nil;
|
|
46
|
+
self.module = nil;
|
|
47
|
+
[FIRApp resetRegistryForTesting];
|
|
48
|
+
[RNFBAppCustomAuthDomains resetCustomDomainsForTesting];
|
|
49
|
+
[FIRConfiguration resetForTesting];
|
|
50
|
+
[super tearDown];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)testSetBridgePathOnSharedEmitter {
|
|
54
|
+
RCTBridge *bridge = [[RCTBridge alloc] init];
|
|
55
|
+
RNFBAppModuleSetBridge(bridge);
|
|
56
|
+
XCTAssertEqual([RNFBRCTEventEmitter shared].bridge, bridge);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (void)testBridgeGetterReturnsSharedEmitterBridge {
|
|
60
|
+
RCTBridge *bridge = [[RCTBridge alloc] init];
|
|
61
|
+
[RNFBRCTEventEmitter shared].bridge = bridge;
|
|
62
|
+
XCTAssertEqual(RNFBAppModuleBridge(), bridge);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void)testInvalidateForwardsToSharedEmitter {
|
|
66
|
+
RNFBRCTEventEmitter *emitter = [RNFBRCTEventEmitter shared];
|
|
67
|
+
[emitter sendEventWithName:@"evt" body:@{@"a" : @1}];
|
|
68
|
+
[emitter addListener:@"evt"];
|
|
69
|
+
[emitter notifyJsReady:YES];
|
|
70
|
+
|
|
71
|
+
RNFBAppModuleInvalidate();
|
|
72
|
+
|
|
73
|
+
NSDictionary *dict = [emitter getListenersDictionary];
|
|
74
|
+
XCTAssertEqualObjects(dict[@"listeners"], @0);
|
|
75
|
+
XCTAssertEqualObjects(dict[@"queued"], @0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (void)testCompleteInitializeAppSetsDomainDataCollectionAndResolves {
|
|
79
|
+
FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"app-id" GCMSenderID:@"sender"];
|
|
80
|
+
FIRApp *app = [[FIRApp alloc] initWithName:@"secondary" options:options];
|
|
81
|
+
[FIRApp registerAppForTesting:app];
|
|
82
|
+
|
|
83
|
+
__block NSDictionary *resolved = nil;
|
|
84
|
+
RNFBAppModuleCompleteInitializeApp(app, @"auth.example.com", @"secondary",
|
|
85
|
+
@{@"automaticDataCollectionEnabled" : @YES}, ^(id result) {
|
|
86
|
+
resolved = result;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
XCTAssertEqualObjects([RNFBAppCustomAuthDomains getCustomDomain:@"secondary"],
|
|
90
|
+
@"auth.example.com");
|
|
91
|
+
XCTAssertTrue(app.isDataCollectionDefaultEnabled);
|
|
92
|
+
XCTAssertEqualObjects(resolved[@"appConfig"][@"name"], @"secondary");
|
|
93
|
+
XCTAssertEqualObjects(resolved[@"options"][@"authDomain"], @"auth.example.com");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
- (FIRApp *)registeredAppNamed:(NSString *)name dataCollection:(BOOL)enabled {
|
|
97
|
+
FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"app-id" GCMSenderID:@"sender"];
|
|
98
|
+
FIRApp *app = [[FIRApp alloc] initWithName:name options:options];
|
|
99
|
+
app.dataCollectionDefaultEnabled = enabled;
|
|
100
|
+
[FIRApp registerAppForTesting:app];
|
|
101
|
+
return app;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
- (void)testCompleteInitializeAppReadsTheBooleanValueNotThePointer {
|
|
105
|
+
FIRApp *app = [self registeredAppNamed:@"secondary" dataCollection:YES];
|
|
106
|
+
|
|
107
|
+
RNFBAppModuleCompleteInitializeApp(app, nil, @"secondary",
|
|
108
|
+
@{@"automaticDataCollectionEnabled" : @NO},
|
|
109
|
+
^(id result){
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
XCTAssertFalse(app.isDataCollectionDefaultEnabled);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
- (void)testCompleteInitializeAppLeavesSDKDefaultWhenKeyMissingOrNonNumeric {
|
|
116
|
+
FIRApp *missing = [self registeredAppNamed:@"missing" dataCollection:YES];
|
|
117
|
+
FIRApp *null = [self registeredAppNamed:@"null" dataCollection:YES];
|
|
118
|
+
|
|
119
|
+
RNFBAppModuleCompleteInitializeApp(missing, nil, @"missing", @{},
|
|
120
|
+
^(id result){
|
|
121
|
+
});
|
|
122
|
+
RNFBAppModuleCompleteInitializeApp(null, nil, @"null",
|
|
123
|
+
@{@"automaticDataCollectionEnabled" : [NSNull null]},
|
|
124
|
+
^(id result){
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Omitted / non-NSNumber keys must not force-disable; SDK / Info.plist default remains.
|
|
128
|
+
XCTAssertTrue(missing.isDataCollectionDefaultEnabled);
|
|
129
|
+
XCTAssertTrue(null.isDataCollectionDefaultEnabled);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
- (void)testCompleteInitializeAppMapsNumericBooleansByTheirValue {
|
|
133
|
+
FIRApp *one = [self registeredAppNamed:@"one" dataCollection:NO];
|
|
134
|
+
FIRApp *zero = [self registeredAppNamed:@"zero" dataCollection:YES];
|
|
135
|
+
|
|
136
|
+
RNFBAppModuleCompleteInitializeApp(one, nil, @"one", @{@"automaticDataCollectionEnabled" : @1},
|
|
137
|
+
^(id result){
|
|
138
|
+
});
|
|
139
|
+
RNFBAppModuleCompleteInitializeApp(zero, nil, @"zero", @{@"automaticDataCollectionEnabled" : @0},
|
|
140
|
+
^(id result){
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
XCTAssertTrue(one.isDataCollectionDefaultEnabled);
|
|
144
|
+
XCTAssertFalse(zero.isDataCollectionDefaultEnabled);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
- (void)testCompleteInitializeAppWithNilConfigLeavesSDKDefault {
|
|
148
|
+
FIRApp *app = [self registeredAppNamed:@"nilconfig" dataCollection:YES];
|
|
149
|
+
|
|
150
|
+
RNFBAppModuleCompleteInitializeApp(app, nil, @"nilconfig", nil,
|
|
151
|
+
^(id result){
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
XCTAssertTrue(app.isDataCollectionDefaultEnabled);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
- (void)testInitializeAppliesTheConfiguredAppLogLevel {
|
|
158
|
+
[self withJSONObject:@{@"app_log_level" : @"debug"}
|
|
159
|
+
perform:^{
|
|
160
|
+
RNFBAppModuleInitialize();
|
|
161
|
+
}];
|
|
162
|
+
|
|
163
|
+
XCTAssertEqual([FIRConfiguration sharedInstance].loggerLevel, FIRLoggerLevelDebug);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
- (void)testInitializeLeavesTheLogLevelAloneWithoutAConfiguredAppLogLevel {
|
|
167
|
+
[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelNotice];
|
|
168
|
+
|
|
169
|
+
[self withJSONObject:@{@"other_key" : @"debug"}
|
|
170
|
+
perform:^{
|
|
171
|
+
RNFBAppModuleInitialize();
|
|
172
|
+
}];
|
|
173
|
+
|
|
174
|
+
XCTAssertEqual([FIRConfiguration sharedInstance].loggerLevel, FIRLoggerLevelNotice);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Swaps the shared firebase.json for the duration of `block`, like the shared-utils tests. */
|
|
178
|
+
- (void)withJSONObject:(NSDictionary *)object perform:(void (^)(void))block {
|
|
179
|
+
RNFBJSON *shared = [RNFBJSON shared];
|
|
180
|
+
id previous = [shared valueForKey:@"implementation"];
|
|
181
|
+
[shared setValue:[[RNFBJSONImplementation alloc] initWithJSONObject:object]
|
|
182
|
+
forKey:@"implementation"];
|
|
183
|
+
@try {
|
|
184
|
+
block();
|
|
185
|
+
} @finally {
|
|
186
|
+
[shared setValue:previous forKey:@"implementation"];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
- (void)testCompleteInitializeAppWithoutAnAppStillStoresDomainAndResolvesEmptySections {
|
|
191
|
+
__block NSDictionary *resolved = nil;
|
|
192
|
+
|
|
193
|
+
RNFBAppModuleCompleteInitializeApp(nil, @"auth.example.com", @"secondary",
|
|
194
|
+
@{@"automaticDataCollectionEnabled" : @YES}, ^(id result) {
|
|
195
|
+
resolved = result;
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
XCTAssertEqualObjects([RNFBAppCustomAuthDomains getCustomDomain:@"secondary"],
|
|
199
|
+
@"auth.example.com");
|
|
200
|
+
XCTAssertEqualObjects(resolved, (@{
|
|
201
|
+
@"options" : @{},
|
|
202
|
+
@"appConfig" : @{@"automaticDataCollectionEnabled" : @NO},
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@end
|
|
@@ -0,0 +1,367 @@
|
|
|
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 <XCTest/XCTest.h>
|
|
18
|
+
|
|
19
|
+
#import <React/RCTBridge.h>
|
|
20
|
+
#import "FirebaseCore/FirebaseCore.h"
|
|
21
|
+
#import "RNFBAppModule.h"
|
|
22
|
+
#import "RNFBAppTurboModules.h"
|
|
23
|
+
#import "RNFBHandleMapStorage-Swift.inc"
|
|
24
|
+
#import "RNFBRCTEventEmitter.h"
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Exercises the shipped `RNFBAppModule.mm` TurboModule shell (compiled into this target
|
|
28
|
+
* against the host TurboModule stubs). The shell only forwards to the C implementation
|
|
29
|
+
* functions, so each test asserts the observable result of the forward.
|
|
30
|
+
*/
|
|
31
|
+
@interface RNFBAppModule (ShellTesting)
|
|
32
|
+
- (void)setBridge:(RCTBridge *)bridge;
|
|
33
|
+
- (RCTBridge *)bridge;
|
|
34
|
+
- (void)invalidate;
|
|
35
|
+
- (facebook::react::ModuleConstants<JS::NativeRNFBTurboApp::Constants>)constantsToExport;
|
|
36
|
+
- (facebook::react::ModuleConstants<JS::NativeRNFBTurboApp::Constants>)getConstants;
|
|
37
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
38
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params;
|
|
39
|
+
+ (BOOL)requiresMainQueueSetup;
|
|
40
|
+
+ (NSString *)moduleName;
|
|
41
|
+
- (void)initializeApp:(NSDictionary *)options
|
|
42
|
+
appConfig:(NSDictionary *)appConfig
|
|
43
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
44
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
45
|
+
- (void)setAutomaticDataCollectionEnabled:(NSString *)appName enabled:(BOOL)enabled;
|
|
46
|
+
- (void)deleteApp:(NSString *)appName
|
|
47
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
48
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
49
|
+
- (void)eventsNotifyReady:(BOOL)ready;
|
|
50
|
+
- (void)eventsGetListeners:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
|
51
|
+
- (void)eventsPing:(NSString *)eventName
|
|
52
|
+
eventBody:(NSDictionary *)eventBody
|
|
53
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
54
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
55
|
+
- (void)eventsAddListener:(NSString *)eventName;
|
|
56
|
+
- (void)eventsRemoveListener:(NSString *)eventName all:(BOOL)all;
|
|
57
|
+
- (void)addListener:(NSString *)eventName;
|
|
58
|
+
- (void)removeListeners:(double)count;
|
|
59
|
+
- (void)metaGetAll:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
|
60
|
+
- (void)jsonGetAll:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
|
61
|
+
- (void)preferencesSetBool:(NSString *)key
|
|
62
|
+
value:(BOOL)value
|
|
63
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
64
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
65
|
+
- (void)preferencesSetString:(NSString *)key
|
|
66
|
+
value:(NSString *)value
|
|
67
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
68
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
69
|
+
- (void)preferencesGetAll:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
|
70
|
+
- (void)preferencesClearAll:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
|
71
|
+
@end
|
|
72
|
+
|
|
73
|
+
@interface RNFBAppModuleShellTests : XCTestCase
|
|
74
|
+
@property(nonatomic, strong) RNFBAppModule *module;
|
|
75
|
+
@end
|
|
76
|
+
|
|
77
|
+
@implementation RNFBAppModuleShellTests
|
|
78
|
+
|
|
79
|
+
- (void)setUp {
|
|
80
|
+
[super setUp];
|
|
81
|
+
[FIRApp resetRegistryForTesting];
|
|
82
|
+
[FIRConfiguration resetForTesting];
|
|
83
|
+
[RNFBAppModuleFirebase resetRegisterLibraryOnceForTesting];
|
|
84
|
+
[RNFBAppCustomAuthDomains resetCustomDomainsForTesting];
|
|
85
|
+
[[RNFBRCTEventEmitter shared] invalidate];
|
|
86
|
+
[RNFBRCTEventEmitter shared].bridge = nil;
|
|
87
|
+
self.module = [[RNFBAppModule alloc] init];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (void)tearDown {
|
|
91
|
+
self.module = nil;
|
|
92
|
+
[[RNFBRCTEventEmitter shared] invalidate];
|
|
93
|
+
[RNFBRCTEventEmitter shared].bridge = nil;
|
|
94
|
+
[FIRApp resetRegistryForTesting];
|
|
95
|
+
[FIRConfiguration resetForTesting];
|
|
96
|
+
[RNFBAppModuleFirebase resetRegisterLibraryOnceForTesting];
|
|
97
|
+
[RNFBAppCustomAuthDomains resetCustomDomainsForTesting];
|
|
98
|
+
[super tearDown];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
- (NSDictionary *)initializeOptionsWithAppID:(NSString *)appID {
|
|
102
|
+
return @{
|
|
103
|
+
@"appId" : appID,
|
|
104
|
+
@"messagingSenderId" : @"sender-id",
|
|
105
|
+
@"apiKey" : @"api-key",
|
|
106
|
+
@"projectId" : @"project-id",
|
|
107
|
+
@"authDomain" : @"auth.example.com",
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
#pragma mark - Module setup
|
|
112
|
+
|
|
113
|
+
- (void)testInitRegistersLibraryOnce {
|
|
114
|
+
XCTAssertEqualObjects([FIRApp lastRegisteredLibraryNameForTesting], @"react-native-firebase");
|
|
115
|
+
XCTAssertEqualObjects([FIRApp lastRegisteredLibraryVersionForTesting], @"unit-test");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
- (void)testExportedModuleNameAndMainQueueSetup {
|
|
119
|
+
XCTAssertEqualObjects([RNFBAppModule moduleName], @"NativeRNFBTurboApp");
|
|
120
|
+
XCTAssertFalse([RNFBAppModule requiresMainQueueSetup]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
- (void)testGetTurboModuleCreatesTheAppSpecModule {
|
|
124
|
+
facebook::react::ObjCTurboModule::InitParams params;
|
|
125
|
+
auto turboModule = [self.module getTurboModule:params];
|
|
126
|
+
|
|
127
|
+
XCTAssertTrue(turboModule != nullptr);
|
|
128
|
+
XCTAssertTrue(std::dynamic_pointer_cast<facebook::react::NativeRNFBTurboAppSpecJSI>(
|
|
129
|
+
turboModule) != nullptr);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
- (void)testSetBridgeAndBridgeGetterUseTheSharedEmitter {
|
|
133
|
+
RCTBridge *bridge = [[RCTBridge alloc] init];
|
|
134
|
+
|
|
135
|
+
[self.module setBridge:bridge];
|
|
136
|
+
|
|
137
|
+
XCTAssertEqual([RNFBRCTEventEmitter shared].bridge, bridge);
|
|
138
|
+
XCTAssertEqual([self.module bridge], bridge);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
- (void)testInvalidateClearsSharedEmitterListeners {
|
|
142
|
+
RNFBRCTEventEmitter *emitter = [RNFBRCTEventEmitter shared];
|
|
143
|
+
[emitter addListener:@"evt"];
|
|
144
|
+
|
|
145
|
+
[self.module invalidate];
|
|
146
|
+
|
|
147
|
+
XCTAssertEqualObjects([emitter getListenersDictionary][@"listeners"], @0);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (void)testConstantsToExportAndGetConstantsListConfiguredApps {
|
|
151
|
+
FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"app-id" GCMSenderID:@"sender"];
|
|
152
|
+
[FIRApp registerAppForTesting:[[FIRApp alloc] initWithName:@"secondary" options:options]];
|
|
153
|
+
|
|
154
|
+
auto exported = [self.module constantsToExport];
|
|
155
|
+
auto fetched = [self.module getConstants];
|
|
156
|
+
|
|
157
|
+
for (NSDictionary *constants in @[ exported.dictionary, fetched.dictionary ]) {
|
|
158
|
+
NSArray *apps = constants[@"NATIVE_FIREBASE_APPS"];
|
|
159
|
+
XCTAssertEqual(apps.count, 1);
|
|
160
|
+
XCTAssertEqualObjects(apps[0][@"appConfig"][@"name"], @"secondary");
|
|
161
|
+
XCTAssertNotNil(constants[@"FIREBASE_RAW_JSON"]);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#pragma mark - Firebase app methods
|
|
166
|
+
|
|
167
|
+
- (void)testInitializeAppConfiguresNamedAppAndResolves {
|
|
168
|
+
__block NSDictionary *resolved = nil;
|
|
169
|
+
|
|
170
|
+
[self.module initializeApp:[self initializeOptionsWithAppID:@"app-id"]
|
|
171
|
+
appConfig:@{@"name" : @"secondary", @"automaticDataCollectionEnabled" : @YES}
|
|
172
|
+
resolve:^(id result) {
|
|
173
|
+
resolved = result;
|
|
174
|
+
}
|
|
175
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
176
|
+
XCTFail(@"unexpected reject %@", message);
|
|
177
|
+
}];
|
|
178
|
+
|
|
179
|
+
XCTAssertEqualObjects(resolved[@"appConfig"][@"name"], @"secondary");
|
|
180
|
+
XCTAssertEqualObjects(resolved[@"appConfig"][@"automaticDataCollectionEnabled"], @YES);
|
|
181
|
+
XCTAssertEqualObjects(resolved[@"options"][@"appId"], @"app-id");
|
|
182
|
+
XCTAssertEqualObjects([RNFBAppModule getCustomDomain:@"secondary"], @"auth.example.com");
|
|
183
|
+
XCTAssertNotNil([FIRApp appNamed:@"secondary"]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
- (void)testInitializeAppRejectsWhenFirebaseRaises {
|
|
187
|
+
NSDictionary *options = [self initializeOptionsWithAppID:@"app-id"];
|
|
188
|
+
NSDictionary *appConfig = @{@"name" : @"secondary"};
|
|
189
|
+
[self.module initializeApp:options
|
|
190
|
+
appConfig:appConfig
|
|
191
|
+
resolve:^(id result) {
|
|
192
|
+
}
|
|
193
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
194
|
+
XCTFail(@"first initialize must not reject: %@", message);
|
|
195
|
+
}];
|
|
196
|
+
|
|
197
|
+
__block NSString *rejectedCode = nil;
|
|
198
|
+
__block NSString *rejectedMessage = nil;
|
|
199
|
+
__block BOOL resolved = NO;
|
|
200
|
+
[self.module initializeApp:options
|
|
201
|
+
appConfig:appConfig
|
|
202
|
+
resolve:^(id result) {
|
|
203
|
+
resolved = YES;
|
|
204
|
+
}
|
|
205
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
206
|
+
rejectedCode = code;
|
|
207
|
+
rejectedMessage = message;
|
|
208
|
+
}];
|
|
209
|
+
|
|
210
|
+
XCTAssertFalse(resolved);
|
|
211
|
+
XCTAssertEqualObjects(rejectedCode, NSInternalInconsistencyException);
|
|
212
|
+
XCTAssertTrue([rejectedMessage containsString:@"already been configured"], @"%@",
|
|
213
|
+
rejectedMessage);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
- (void)testSetAutomaticDataCollectionEnabledForwardsToTheNamedApp {
|
|
217
|
+
FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"app-id" GCMSenderID:@"sender"];
|
|
218
|
+
FIRApp *app = [[FIRApp alloc] initWithName:@"secondary" options:options];
|
|
219
|
+
[FIRApp registerAppForTesting:app];
|
|
220
|
+
|
|
221
|
+
[self.module setAutomaticDataCollectionEnabled:@"secondary" enabled:YES];
|
|
222
|
+
|
|
223
|
+
XCTAssertTrue(app.isDataCollectionDefaultEnabled);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
- (void)testDeleteAppForwardsAndResolvesNull {
|
|
227
|
+
FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"app-id" GCMSenderID:@"sender"];
|
|
228
|
+
[FIRApp registerAppForTesting:[[FIRApp alloc] initWithName:@"secondary" options:options]];
|
|
229
|
+
__block id resolved = @"unset";
|
|
230
|
+
|
|
231
|
+
[self.module deleteApp:@"secondary"
|
|
232
|
+
resolve:^(id result) {
|
|
233
|
+
resolved = result;
|
|
234
|
+
}
|
|
235
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
236
|
+
XCTFail(@"unexpected reject %@", message);
|
|
237
|
+
}];
|
|
238
|
+
|
|
239
|
+
XCTAssertEqualObjects(resolved, [NSNull null]);
|
|
240
|
+
XCTAssertNil([FIRApp appNamed:@"secondary"]);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
- (void)testSetLogLevelForwardsToTheMapper {
|
|
244
|
+
[self.module setLogLevel:@"warn"];
|
|
245
|
+
XCTAssertEqual([FIRConfiguration sharedInstance].loggerLevel, FIRLoggerLevelWarning);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#pragma mark - Event methods
|
|
249
|
+
|
|
250
|
+
- (void)testEventsForwardToTheSharedEmitter {
|
|
251
|
+
RNFBRCTEventEmitter *emitter = [RNFBRCTEventEmitter shared];
|
|
252
|
+
|
|
253
|
+
[self.module eventsAddListener:@"evt"];
|
|
254
|
+
[self.module eventsAddListener:@"evt"];
|
|
255
|
+
XCTAssertEqualObjects([emitter getListenersDictionary][@"listeners"], @2);
|
|
256
|
+
|
|
257
|
+
[self.module eventsRemoveListener:@"evt" all:NO];
|
|
258
|
+
XCTAssertEqualObjects([emitter getListenersDictionary][@"listeners"], @1);
|
|
259
|
+
[self.module eventsRemoveListener:@"evt" all:YES];
|
|
260
|
+
XCTAssertEqualObjects([emitter getListenersDictionary][@"listeners"], @0);
|
|
261
|
+
|
|
262
|
+
__block NSDictionary *listeners = nil;
|
|
263
|
+
[self.module
|
|
264
|
+
eventsGetListeners:^(id result) {
|
|
265
|
+
listeners = result;
|
|
266
|
+
}
|
|
267
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
268
|
+
XCTFail(@"unexpected reject %@", message);
|
|
269
|
+
}];
|
|
270
|
+
XCTAssertEqualObjects(listeners[@"listeners"], @0);
|
|
271
|
+
|
|
272
|
+
__block id pinged = nil;
|
|
273
|
+
[self.module eventsPing:@"evt"
|
|
274
|
+
eventBody:@{@"a" : @1}
|
|
275
|
+
resolve:^(id result) {
|
|
276
|
+
pinged = result;
|
|
277
|
+
}
|
|
278
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
279
|
+
XCTFail(@"unexpected reject %@", message);
|
|
280
|
+
}];
|
|
281
|
+
XCTAssertEqualObjects(pinged, @{@"a" : @1});
|
|
282
|
+
XCTAssertEqualObjects([emitter getListenersDictionary][@"queued"], @1);
|
|
283
|
+
|
|
284
|
+
[self.module eventsNotifyReady:YES];
|
|
285
|
+
XCTAssertEqualObjects([emitter getListenersDictionary][@"queued"], @0);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
- (void)testBuiltInEmitterCallsAreNoOps {
|
|
289
|
+
[self.module addListener:@"evt"];
|
|
290
|
+
[self.module removeListeners:1];
|
|
291
|
+
|
|
292
|
+
XCTAssertEqualObjects([[RNFBRCTEventEmitter shared] getListenersDictionary][@"listeners"], @0);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
#pragma mark - Meta, JSON and preferences
|
|
296
|
+
|
|
297
|
+
- (void)testMetaAndJSONGetAllResolveDictionaries {
|
|
298
|
+
__block id meta = nil;
|
|
299
|
+
__block id json = nil;
|
|
300
|
+
|
|
301
|
+
[self.module
|
|
302
|
+
metaGetAll:^(id result) {
|
|
303
|
+
meta = result;
|
|
304
|
+
}
|
|
305
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
306
|
+
XCTFail(@"unexpected reject %@", message);
|
|
307
|
+
}];
|
|
308
|
+
[self.module
|
|
309
|
+
jsonGetAll:^(id result) {
|
|
310
|
+
json = result;
|
|
311
|
+
}
|
|
312
|
+
reject:^(NSString *code, NSString *message, NSError *error) {
|
|
313
|
+
XCTFail(@"unexpected reject %@", message);
|
|
314
|
+
}];
|
|
315
|
+
|
|
316
|
+
XCTAssertTrue([meta isKindOfClass:[NSDictionary class]]);
|
|
317
|
+
XCTAssertTrue([json isKindOfClass:[NSDictionary class]]);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
- (void)testPreferencesRoundTripThroughTheShell {
|
|
321
|
+
RCTPromiseRejectBlock failOnReject = ^(NSString *code, NSString *message, NSError *error) {
|
|
322
|
+
XCTFail(@"unexpected reject %@", message);
|
|
323
|
+
};
|
|
324
|
+
__block id setBoolResult = nil;
|
|
325
|
+
__block id setStringResult = nil;
|
|
326
|
+
__block NSDictionary *all = nil;
|
|
327
|
+
__block id clearResult = nil;
|
|
328
|
+
__block NSDictionary *afterClear = nil;
|
|
329
|
+
|
|
330
|
+
[self.module preferencesSetBool:@"shell_bool"
|
|
331
|
+
value:YES
|
|
332
|
+
resolve:^(id result) {
|
|
333
|
+
setBoolResult = result;
|
|
334
|
+
}
|
|
335
|
+
reject:failOnReject];
|
|
336
|
+
[self.module preferencesSetString:@"shell_string"
|
|
337
|
+
value:@"shell-value"
|
|
338
|
+
resolve:^(id result) {
|
|
339
|
+
setStringResult = result;
|
|
340
|
+
}
|
|
341
|
+
reject:failOnReject];
|
|
342
|
+
[self.module
|
|
343
|
+
preferencesGetAll:^(id result) {
|
|
344
|
+
all = result;
|
|
345
|
+
}
|
|
346
|
+
reject:failOnReject];
|
|
347
|
+
[self.module
|
|
348
|
+
preferencesClearAll:^(id result) {
|
|
349
|
+
clearResult = result;
|
|
350
|
+
}
|
|
351
|
+
reject:failOnReject];
|
|
352
|
+
[self.module
|
|
353
|
+
preferencesGetAll:^(id result) {
|
|
354
|
+
afterClear = result;
|
|
355
|
+
}
|
|
356
|
+
reject:failOnReject];
|
|
357
|
+
|
|
358
|
+
XCTAssertEqualObjects(setBoolResult, [NSNull null]);
|
|
359
|
+
XCTAssertEqualObjects(setStringResult, [NSNull null]);
|
|
360
|
+
XCTAssertEqualObjects(all[@"shell_bool"], @YES);
|
|
361
|
+
XCTAssertEqualObjects(all[@"shell_string"], @"shell-value");
|
|
362
|
+
XCTAssertEqualObjects(clearResult, [NSNull null]);
|
|
363
|
+
XCTAssertNil(afterClear[@"shell_bool"]);
|
|
364
|
+
XCTAssertNil(afterClear[@"shell_string"]);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
@end
|