@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
|
@@ -15,13 +15,10 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
#if __has_include(<FirebaseCore/FirebaseCore.h>)
|
|
19
|
-
#import <FirebaseCore/FirebaseCore.h>
|
|
20
|
-
#else
|
|
21
|
-
@import FirebaseCore;
|
|
22
|
-
#endif
|
|
23
18
|
#import <React/RCTConvert.h>
|
|
24
19
|
|
|
20
|
+
@class FIRApp;
|
|
21
|
+
|
|
25
22
|
@interface RCTConvert (FIRApp)
|
|
26
23
|
+ (FIRApp *)firAppFromString:(NSString *)appName;
|
|
27
24
|
@end
|
|
@@ -16,15 +16,20 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
#import "RCTConvert+FIRApp.h"
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
#if __has_include(<RNFBApp/RNFBApp-Swift.h>)
|
|
21
|
+
#import <RNFBApp/RNFBApp-Swift.h>
|
|
22
|
+
#elif __has_include("RNFBApp-Swift.h")
|
|
23
|
+
#import "RNFBApp-Swift.h"
|
|
24
|
+
#elif __has_include("RNFBHandleMapStorage-Swift.inc")
|
|
25
|
+
#import "RNFBHandleMapStorage-Swift.inc"
|
|
26
|
+
#else
|
|
27
|
+
#error "RNFBApp Swift interface not found"
|
|
28
|
+
#endif
|
|
20
29
|
|
|
21
30
|
@implementation RCTConvert (FIRApp)
|
|
22
31
|
+ (FIRApp *)firAppFromString:(NSString *)appName {
|
|
23
|
-
|
|
24
|
-
return [FIRApp defaultApp];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return [FIRApp appNamed:appName];
|
|
32
|
+
return (FIRApp *)[RCTConvertFIRApp firAppFromString:appName];
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
RCT_CUSTOM_CONVERTER(FIRApp *, FIRApp, [self firAppFromString:[self NSString:json]]);
|
|
@@ -15,13 +15,10 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
#if __has_include(<FirebaseCore/FirebaseCore.h>)
|
|
19
|
-
#import <FirebaseCore/FirebaseCore.h>
|
|
20
|
-
#else
|
|
21
|
-
@import FirebaseCore;
|
|
22
|
-
#endif
|
|
23
18
|
#import <React/RCTConvert.h>
|
|
24
19
|
|
|
20
|
+
@class FIROptions;
|
|
21
|
+
|
|
25
22
|
@interface RCTConvert (FIROptions)
|
|
26
23
|
+ (FIROptions *)convertRawOptions:(NSDictionary *)rawOptions;
|
|
27
24
|
@end
|
|
@@ -17,19 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
#import "RCTConvert+FIROptions.h"
|
|
19
19
|
|
|
20
|
+
#if __has_include(<RNFBApp/RNFBApp-Swift.h>)
|
|
21
|
+
#import <RNFBApp/RNFBApp-Swift.h>
|
|
22
|
+
#elif __has_include("RNFBApp-Swift.h")
|
|
23
|
+
#import "RNFBApp-Swift.h"
|
|
24
|
+
#elif __has_include("RNFBHandleMapStorage-Swift.inc")
|
|
25
|
+
#import "RNFBHandleMapStorage-Swift.inc"
|
|
26
|
+
#else
|
|
27
|
+
#error "RNFBApp Swift interface not found"
|
|
28
|
+
#endif
|
|
29
|
+
|
|
20
30
|
@implementation RCTConvert (FIROptions)
|
|
21
31
|
|
|
22
32
|
+ (FIROptions *)convertRawOptions:(NSDictionary *)rawOptions {
|
|
23
|
-
FIROptions *
|
|
24
|
-
[[FIROptions alloc] initWithGoogleAppID:[rawOptions valueForKey:@"appId"]
|
|
25
|
-
GCMSenderID:[rawOptions valueForKey:@"messagingSenderId"]];
|
|
26
|
-
firOptions.APIKey = [rawOptions valueForKey:@"apiKey"];
|
|
27
|
-
firOptions.projectID = [rawOptions valueForKey:@"projectId"];
|
|
28
|
-
firOptions.clientID = [rawOptions valueForKey:@"clientId"];
|
|
29
|
-
firOptions.databaseURL = [rawOptions valueForKey:@"databaseURL"];
|
|
30
|
-
firOptions.storageBucket = [rawOptions valueForKey:@"storageBucket"];
|
|
31
|
-
firOptions.bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"];
|
|
32
|
-
return firOptions;
|
|
33
|
+
return (FIROptions *)[RCTConvertFIROptions convertRawOptions:rawOptions];
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
RCT_CUSTOM_CONVERTER(FIROptions *, FIROptions, [self convertRawOptions:[self NSDictionary:json]]);
|
|
@@ -0,0 +1,86 @@
|
|
|
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 registry previously hard-wired to `[FIRApp defaultApp]` / `[FIRApp appNamed:]`.
|
|
26
|
+
*
|
|
27
|
+
* Production adapts live `FIRApp` class methods; unit tests inject a registry double.
|
|
28
|
+
*/
|
|
29
|
+
@objc public protocol RNFBFIRAppLookingUp: AnyObject {
|
|
30
|
+
@objc(defaultApp)
|
|
31
|
+
func defaultApp() -> AnyObject?
|
|
32
|
+
|
|
33
|
+
@objc(appNamed:)
|
|
34
|
+
func appNamed(_ name: String) -> AnyObject?
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Adapts `FirebaseApp.app()` / `FirebaseApp.app(name:)` (`+[FIRApp defaultApp]` /
|
|
39
|
+
* `+[FIRApp appNamed:]`) for `RCTConvertFIRApp`.
|
|
40
|
+
*/
|
|
41
|
+
@objc(RNFBFIRAppRegistryAdapter)
|
|
42
|
+
final class RNFBFIRAppRegistryAdapter: NSObject, RNFBFIRAppLookingUp {
|
|
43
|
+
@objc static let shared = RNFBFIRAppRegistryAdapter()
|
|
44
|
+
|
|
45
|
+
func defaultApp() -> AnyObject? {
|
|
46
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
47
|
+
RNFBFirebaseAppClient.defaultApp()
|
|
48
|
+
#else
|
|
49
|
+
FirebaseApp.app()
|
|
50
|
+
#endif
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func appNamed(_ name: String) -> AnyObject? {
|
|
54
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
55
|
+
RNFBFirebaseAppClient.app(named: name)
|
|
56
|
+
#else
|
|
57
|
+
FirebaseApp.app(name: name)
|
|
58
|
+
#endif
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* FIRApp name → instance lookup previously inline in `RCTConvert+FIRApp.m`.
|
|
64
|
+
*
|
|
65
|
+
* Mirrors pre-port:
|
|
66
|
+
* - `DEFAULT_APP_DISPLAY_NAME` (`[DEFAULT]`) → `defaultApp`
|
|
67
|
+
* - any other name → `appNamed:`
|
|
68
|
+
*/
|
|
69
|
+
@objc(RCTConvertFIRApp)
|
|
70
|
+
public final class RCTConvertFIRApp: NSObject {
|
|
71
|
+
/// Matches `DEFAULT_APP_DISPLAY_NAME` in `RNFBSharedUtils.m`.
|
|
72
|
+
private static let defaultAppDisplayName = "[DEFAULT]"
|
|
73
|
+
|
|
74
|
+
@objc(firAppFromString:)
|
|
75
|
+
public static func firApp(fromString appName: String) -> AnyObject? {
|
|
76
|
+
firApp(fromString: appName, registry: RNFBFIRAppRegistryAdapter.shared)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@objc(firAppFromString:registry:)
|
|
80
|
+
public static func firApp(fromString appName: String, registry: RNFBFIRAppLookingUp) -> AnyObject? {
|
|
81
|
+
if appName == defaultAppDisplayName {
|
|
82
|
+
return registry.defaultApp()
|
|
83
|
+
}
|
|
84
|
+
return registry.appNamed(appName)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
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
|
|
18
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
19
|
+
import RNFBFirebase
|
|
20
|
+
#else
|
|
21
|
+
import FirebaseCore
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Mutable FIROptions fields set by `convertRawOptions`.
|
|
26
|
+
*
|
|
27
|
+
* Production adapts live `FIROptions`; unit tests inject doubles.
|
|
28
|
+
*/
|
|
29
|
+
@objc public protocol RNFBFIROptionsConfiguring: AnyObject {
|
|
30
|
+
var APIKey: String? { get set }
|
|
31
|
+
var projectID: String? { get set }
|
|
32
|
+
var clientID: String? { get set }
|
|
33
|
+
var databaseURL: String? { get set }
|
|
34
|
+
var storageBucket: String? { get set }
|
|
35
|
+
var bundleID: String? { get set }
|
|
36
|
+
/// Set by `initializeApp` options mapping (`appGroupId`); unused by `convertRawOptions`.
|
|
37
|
+
var appGroupID: String? { get set }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates a FIROptions-like object from Google App ID + GCM sender ID.
|
|
42
|
+
*
|
|
43
|
+
* Production wraps `[[FIROptions alloc] initWithGoogleAppID:GCMSenderID:]`.
|
|
44
|
+
*/
|
|
45
|
+
@objc public protocol RNFBFIROptionsCreating: AnyObject {
|
|
46
|
+
@objc(createWithGoogleAppID:gcmSenderID:)
|
|
47
|
+
func create(googleAppID: String?, gcmSenderID: String?) -> RNFBFIROptionsConfiguring
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Bundle identifier source previously hard-wired to
|
|
52
|
+
* `[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]`.
|
|
53
|
+
*/
|
|
54
|
+
@objc public protocol RNFBBundleIdentifierProviding: AnyObject {
|
|
55
|
+
@objc(bundleIdentifier)
|
|
56
|
+
var bundleIdentifier: String? { get }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Single FIROptions construction path. Dynamic mode asks the opaque facade. Shipped mode
|
|
61
|
+
* builds `FirebaseOptions` through the Swift overlay initializer.
|
|
62
|
+
*/
|
|
63
|
+
enum RNFBFIROptionsAllocation {
|
|
64
|
+
static func create(googleAppID: String?, gcmSenderID: String?) -> NSObject {
|
|
65
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
66
|
+
RNFBFirebaseOptionsClient.create(googleAppID: googleAppID, gcmSenderID: gcmSenderID)
|
|
67
|
+
#else
|
|
68
|
+
// Pre-port forwarded nil into `initWithGoogleAppID:GCMSenderID:`, which leaves the key
|
|
69
|
+
// unset. The Swift overlay initializer takes non-optional strings, so build with empty
|
|
70
|
+
// placeholders and clear the keys for nil input. KVC forwards nil to the ObjC setters,
|
|
71
|
+
// which remove the same dictionary entries the nil-initializer would never have added.
|
|
72
|
+
let options = FirebaseOptions(googleAppID: googleAppID ?? "", gcmSenderID: gcmSenderID ?? "")
|
|
73
|
+
if googleAppID == nil {
|
|
74
|
+
options.setValue(nil, forKey: "googleAppID")
|
|
75
|
+
}
|
|
76
|
+
if gcmSenderID == nil {
|
|
77
|
+
options.setValue(nil, forKey: "GCMSenderID")
|
|
78
|
+
}
|
|
79
|
+
return options
|
|
80
|
+
#endif
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#if RNFB_DYNAMIC_FIREBASE_PROBE
|
|
85
|
+
/**
|
|
86
|
+
* Wraps a live options object from `RNFBFirebaseOptionsClient` without naming Firebase types.
|
|
87
|
+
*/
|
|
88
|
+
@objc(RNFBFIROptionsConfiguringAdapter)
|
|
89
|
+
final class RNFBFIROptionsConfiguringAdapter: NSObject, RNFBFIROptionsConfiguring {
|
|
90
|
+
@objc let options: NSObject
|
|
91
|
+
|
|
92
|
+
init(_ options: NSObject) {
|
|
93
|
+
self.options = options
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var APIKey: String? {
|
|
97
|
+
get { RNFBFirebaseOptionsClient.apiKey(options) }
|
|
98
|
+
set { RNFBFirebaseOptionsClient.setAPIKey(newValue, on: options) }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var projectID: String? {
|
|
102
|
+
get { RNFBFirebaseOptionsClient.projectID(options) }
|
|
103
|
+
set { RNFBFirebaseOptionsClient.setProjectID(newValue, on: options) }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var clientID: String? {
|
|
107
|
+
get { RNFBFirebaseOptionsClient.clientID(options) }
|
|
108
|
+
set { RNFBFirebaseOptionsClient.setClientID(newValue, on: options) }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var databaseURL: String? {
|
|
112
|
+
get { RNFBFirebaseOptionsClient.databaseURL(options) }
|
|
113
|
+
set { RNFBFirebaseOptionsClient.setDatabaseURL(newValue, on: options) }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var storageBucket: String? {
|
|
117
|
+
get { RNFBFirebaseOptionsClient.storageBucket(options) }
|
|
118
|
+
set { RNFBFirebaseOptionsClient.setStorageBucket(newValue, on: options) }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var bundleID: String? {
|
|
122
|
+
get { RNFBFirebaseOptionsClient.bundleID(options) }
|
|
123
|
+
set { RNFBFirebaseOptionsClient.setBundleID(newValue, on: options) }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var appGroupID: String? {
|
|
127
|
+
get { RNFBFirebaseOptionsClient.appGroupID(options) }
|
|
128
|
+
set { RNFBFirebaseOptionsClient.setAppGroupID(newValue, on: options) }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
#else
|
|
132
|
+
/**
|
|
133
|
+
* Wraps live `FirebaseOptions` for `RNFBFIROptionsConfiguring`.
|
|
134
|
+
*
|
|
135
|
+
* Swift overlays rename / tighten optionality (`apiKey`, non-optional `bundleID`),
|
|
136
|
+
* so a direct `extension FirebaseOptions: RNFBFIROptionsConfiguring` does not compile.
|
|
137
|
+
*/
|
|
138
|
+
@objc(RNFBFIROptionsConfiguringAdapter)
|
|
139
|
+
final class RNFBFIROptionsConfiguringAdapter: NSObject, RNFBFIROptionsConfiguring {
|
|
140
|
+
@objc let options: FirebaseOptions
|
|
141
|
+
|
|
142
|
+
init(_ options: NSObject) {
|
|
143
|
+
self.options = options as! FirebaseOptions
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var APIKey: String? {
|
|
147
|
+
get { options.apiKey }
|
|
148
|
+
set { options.apiKey = newValue }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var projectID: String? {
|
|
152
|
+
get { options.projectID }
|
|
153
|
+
set { options.projectID = newValue }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
var clientID: String? {
|
|
157
|
+
get { options.clientID }
|
|
158
|
+
set { options.clientID = newValue }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var databaseURL: String? {
|
|
162
|
+
get { options.databaseURL }
|
|
163
|
+
set { options.databaseURL = newValue }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var storageBucket: String? {
|
|
167
|
+
get { options.storageBucket }
|
|
168
|
+
set { options.storageBucket = newValue }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var bundleID: String? {
|
|
172
|
+
get { options.bundleID }
|
|
173
|
+
// The Swift overlay types `bundleID` as non-optional. KVC forwards nil to the ObjC
|
|
174
|
+
// setter like pre-port `options.bundleID = nil` did.
|
|
175
|
+
set { options.setValue(newValue, forKey: "bundleID") }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var appGroupID: String? {
|
|
179
|
+
get { options.appGroupID }
|
|
180
|
+
set { options.appGroupID = newValue }
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
#endif
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Adapts `FirebaseOptions` / `FIROptions` for `RCTConvertFIROptions`.
|
|
187
|
+
*/
|
|
188
|
+
@objc(RNFBFIROptionsFactoryAdapter)
|
|
189
|
+
final class RNFBFIROptionsFactoryAdapter: NSObject, RNFBFIROptionsCreating {
|
|
190
|
+
@objc static let shared = RNFBFIROptionsFactoryAdapter()
|
|
191
|
+
|
|
192
|
+
@objc(createWithGoogleAppID:gcmSenderID:)
|
|
193
|
+
func create(googleAppID: String?, gcmSenderID: String?) -> RNFBFIROptionsConfiguring {
|
|
194
|
+
RNFBFIROptionsConfiguringAdapter(
|
|
195
|
+
RNFBFIROptionsAllocation.create(googleAppID: googleAppID, gcmSenderID: gcmSenderID)
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Adapts mainBundle CFBundleIdentifier for `RCTConvertFIROptions`.
|
|
202
|
+
*/
|
|
203
|
+
@objc(RNFBMainBundleIdentifierProvider)
|
|
204
|
+
final class RNFBMainBundleIdentifierProvider: NSObject, RNFBBundleIdentifierProviding {
|
|
205
|
+
@objc static let shared = RNFBMainBundleIdentifierProvider()
|
|
206
|
+
|
|
207
|
+
@objc var bundleIdentifier: String? {
|
|
208
|
+
Bundle.main.object(forInfoDictionaryKey: "CFBundleIdentifier") as? String
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Raw JS options dict → FIROptions mapping previously inline in `RCTConvert+FIROptions.m`.
|
|
214
|
+
*
|
|
215
|
+
* Mirrors pre-port:
|
|
216
|
+
* - init with `appId` / `messagingSenderId`
|
|
217
|
+
* - set APIKey / projectID / clientID / databaseURL / storageBucket from dict keys
|
|
218
|
+
* - bundleID from the injected bundle-identifier provider
|
|
219
|
+
*/
|
|
220
|
+
@objc(RCTConvertFIROptions)
|
|
221
|
+
public final class RCTConvertFIROptions: NSObject {
|
|
222
|
+
/// Unwraps a configuring adapter to the live `FIROptions` object.
|
|
223
|
+
static func liveFIROptions(from configured: RNFBFIROptionsConfiguring) -> AnyObject {
|
|
224
|
+
if let adapter = configured as? RNFBFIROptionsConfiguringAdapter {
|
|
225
|
+
return adapter.options
|
|
226
|
+
}
|
|
227
|
+
return configured
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/// Production entry used by `RCTConvert+FIROptions.m` — returns live `FIROptions`.
|
|
231
|
+
@objc(convertRawOptions:)
|
|
232
|
+
public static func convertRawOptions(_ rawOptions: NSDictionary) -> AnyObject {
|
|
233
|
+
let configured = convertRawOptions(
|
|
234
|
+
rawOptions,
|
|
235
|
+
optionsFactory: RNFBFIROptionsFactoryAdapter.shared,
|
|
236
|
+
bundleIDProvider: RNFBMainBundleIdentifierProvider.shared
|
|
237
|
+
)
|
|
238
|
+
return liveFIROptions(from: configured)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@objc(convertRawOptions:optionsFactory:bundleIDProvider:)
|
|
242
|
+
public static func convertRawOptions(
|
|
243
|
+
_ rawOptions: NSDictionary,
|
|
244
|
+
optionsFactory: RNFBFIROptionsCreating,
|
|
245
|
+
bundleIDProvider: RNFBBundleIdentifierProviding
|
|
246
|
+
) -> RNFBFIROptionsConfiguring {
|
|
247
|
+
let options = optionsFactory.create(
|
|
248
|
+
googleAppID: rawOptions.value(forKey: "appId") as? String,
|
|
249
|
+
gcmSenderID: rawOptions.value(forKey: "messagingSenderId") as? String
|
|
250
|
+
)
|
|
251
|
+
options.APIKey = rawOptions.value(forKey: "apiKey") as? String
|
|
252
|
+
options.projectID = rawOptions.value(forKey: "projectId") as? String
|
|
253
|
+
options.clientID = rawOptions.value(forKey: "clientId") as? String
|
|
254
|
+
options.databaseURL = rawOptions.value(forKey: "databaseURL") as? String
|
|
255
|
+
options.storageBucket = rawOptions.value(forKey: "storageBucket") as? String
|
|
256
|
+
options.bundleID = bundleIDProvider.bundleIdentifier
|
|
257
|
+
return options
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Process-wide custom auth-domain store previously owned by `RNFBAppModule.mm`
|
|
21
|
+
* (`static NSMutableDictionary *customAuthDomains`).
|
|
22
|
+
*
|
|
23
|
+
* Mirrors pre-port:
|
|
24
|
+
* - set non-nil → store under `appName` (lazy-init dictionary on first non-nil set)
|
|
25
|
+
* - set nil → `removeObject(forKey:)` (no-op when dictionary is still nil)
|
|
26
|
+
* - get → dictionary lookup (nil if missing / dictionary unset)
|
|
27
|
+
* - synchronized on a dedicated lock (pre-port `@synchronized(self)` on class methods)
|
|
28
|
+
*/
|
|
29
|
+
@objc(RNFBAppCustomAuthDomains)
|
|
30
|
+
public final class RNFBAppCustomAuthDomains: NSObject {
|
|
31
|
+
private static let lock = NSObject()
|
|
32
|
+
private static var customAuthDomains: NSMutableDictionary?
|
|
33
|
+
|
|
34
|
+
@objc(getCustomDomain:)
|
|
35
|
+
public static func getCustomDomain(_ appName: String) -> String? {
|
|
36
|
+
objc_sync_enter(lock)
|
|
37
|
+
defer { objc_sync_exit(lock) }
|
|
38
|
+
return customAuthDomains?[appName] as? String
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@objc(setCustomDomain:forAppName:)
|
|
42
|
+
public static func setCustomDomain(_ authDomain: String?, forAppName appName: String) {
|
|
43
|
+
objc_sync_enter(lock)
|
|
44
|
+
defer { objc_sync_exit(lock) }
|
|
45
|
+
if let authDomain {
|
|
46
|
+
if customAuthDomains == nil {
|
|
47
|
+
customAuthDomains = NSMutableDictionary()
|
|
48
|
+
}
|
|
49
|
+
customAuthDomains![appName] = authDomain
|
|
50
|
+
} else {
|
|
51
|
+
// Pre-port: messaging nil dictionary is a no-op.
|
|
52
|
+
customAuthDomains?.removeObject(forKey: appName)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// Clears all stored domains. Unit-test / HostStub seam only.
|
|
57
|
+
@objc(resetCustomDomainsForTesting)
|
|
58
|
+
public static func resetCustomDomainsForTesting() {
|
|
59
|
+
objc_sync_enter(lock)
|
|
60
|
+
defer { objc_sync_exit(lock) }
|
|
61
|
+
customAuthDomains?.removeAllObjects()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Name resolution for `-[RNFBAppModule initializeApp:appConfig:resolve:reject:]`.
|
|
21
|
+
*
|
|
22
|
+
* Mirrors pre-port:
|
|
23
|
+
* - `jsAppName` = `name` when `name.length > 0`, else `DEFAULT_APP_DISPLAY_NAME` (`[DEFAULT]`)
|
|
24
|
+
* - `isDefaultApp` when `!name` or name equals `[DEFAULT]`
|
|
25
|
+
* (empty string → `jsAppName` `[DEFAULT]` but `isDefaultApp` == false)
|
|
26
|
+
*/
|
|
27
|
+
@objc(RNFBAppInitializeNameResolution)
|
|
28
|
+
public final class RNFBAppInitializeNameResolution: NSObject {
|
|
29
|
+
@objc public let appName: String?
|
|
30
|
+
@objc public let jsAppName: String
|
|
31
|
+
@objc public let isDefaultApp: Bool
|
|
32
|
+
|
|
33
|
+
@objc public init(appName: String?, jsAppName: String, isDefaultApp: Bool) {
|
|
34
|
+
self.appName = appName
|
|
35
|
+
self.jsAppName = jsAppName
|
|
36
|
+
self.isDefaultApp = isDefaultApp
|
|
37
|
+
super.init()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Name / FIROptions / authDomain mapping previously inline in
|
|
43
|
+
* `-[RNFBAppModule initializeApp:appConfig:resolve:reject:]`.
|
|
44
|
+
*
|
|
45
|
+
* Distinct from `RCTConvertFIROptions.convertRawOptions`:
|
|
46
|
+
* - optional fields skip assignment when value `isEqual:[NSNull null]`
|
|
47
|
+
* - uses JS keys `iosBundleId` / `iosClientId` / `appGroupId` (not `clientId` + bundle provider)
|
|
48
|
+
*/
|
|
49
|
+
@objc(RNFBAppInitializeOptionsMapper)
|
|
50
|
+
public final class RNFBAppInitializeOptionsMapper: NSObject {
|
|
51
|
+
/// Matches `DEFAULT_APP_DISPLAY_NAME` in `RNFBSharedUtils.m`.
|
|
52
|
+
private static let defaultAppDisplayName = "[DEFAULT]"
|
|
53
|
+
|
|
54
|
+
@objc(resolveNameFromAppConfig:)
|
|
55
|
+
public static func resolveName(from appConfig: NSDictionary) -> RNFBAppInitializeNameResolution {
|
|
56
|
+
let appName = appConfig.value(forKey: "name") as? String
|
|
57
|
+
let jsAppName: String
|
|
58
|
+
if let appName, appName.count > 0 {
|
|
59
|
+
jsAppName = appName
|
|
60
|
+
} else {
|
|
61
|
+
jsAppName = defaultAppDisplayName
|
|
62
|
+
}
|
|
63
|
+
let isDefaultApp = appName == nil || appName == defaultAppDisplayName
|
|
64
|
+
return RNFBAppInitializeNameResolution(
|
|
65
|
+
appName: appName,
|
|
66
|
+
jsAppName: jsAppName,
|
|
67
|
+
isDefaultApp: isDefaultApp
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@objc(buildOptionsFrom:optionsFactory:)
|
|
72
|
+
public static func buildOptions(
|
|
73
|
+
from options: NSDictionary,
|
|
74
|
+
optionsFactory: RNFBFIROptionsCreating
|
|
75
|
+
) -> RNFBFIROptionsConfiguring {
|
|
76
|
+
let firOptions = optionsFactory.create(
|
|
77
|
+
googleAppID: options.value(forKey: "appId") as? String,
|
|
78
|
+
gcmSenderID: options.value(forKey: "messagingSenderId") as? String
|
|
79
|
+
)
|
|
80
|
+
firOptions.APIKey = options.value(forKey: "apiKey") as? String
|
|
81
|
+
firOptions.projectID = options.value(forKey: "projectId") as? String
|
|
82
|
+
if shouldAssignOptionalField(options.value(forKey: "databaseURL")) {
|
|
83
|
+
firOptions.databaseURL = options.value(forKey: "databaseURL") as? String
|
|
84
|
+
}
|
|
85
|
+
if shouldAssignOptionalField(options.value(forKey: "storageBucket")) {
|
|
86
|
+
firOptions.storageBucket = options.value(forKey: "storageBucket") as? String
|
|
87
|
+
}
|
|
88
|
+
if shouldAssignOptionalField(options.value(forKey: "iosBundleId")) {
|
|
89
|
+
firOptions.bundleID = options.value(forKey: "iosBundleId") as? String
|
|
90
|
+
}
|
|
91
|
+
if shouldAssignOptionalField(options.value(forKey: "iosClientId")) {
|
|
92
|
+
firOptions.clientID = options.value(forKey: "iosClientId") as? String
|
|
93
|
+
}
|
|
94
|
+
if shouldAssignOptionalField(options.value(forKey: "appGroupId")) {
|
|
95
|
+
firOptions.appGroupID = options.value(forKey: "appGroupId") as? String
|
|
96
|
+
}
|
|
97
|
+
return firOptions
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@objc(authDomainFromOptions:)
|
|
101
|
+
public static func authDomain(from options: NSDictionary) -> String? {
|
|
102
|
+
options.value(forKey: "authDomain") as? String
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// Pre-port: `![[options valueForKey:key] isEqual:[NSNull null]]`
|
|
106
|
+
/// (missing/nil → assign; `NSNull` → skip).
|
|
107
|
+
private static func shouldAssignOptionalField(_ value: Any?) -> Bool {
|
|
108
|
+
guard let value else {
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
return !(value as AnyObject).isEqual(NSNull())
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Log-level string → `FIRLoggerLevel` raw-value mapping previously inline in
|
|
21
|
+
* `-[RNFBAppModule setLogLevel:]`.
|
|
22
|
+
*
|
|
23
|
+
* Mirrors pre-port (`FIRLoggerLevel` raw values from FirebaseCore):
|
|
24
|
+
* - `"verbose"` / `"debug"` → `FIRLoggerLevelDebug` (7)
|
|
25
|
+
* - `"info"` → `FIRLoggerLevelInfo` (6)
|
|
26
|
+
* - `"warn"` → `FIRLoggerLevelWarning` (4)
|
|
27
|
+
* - else (including nil / unknown) → `FIRLoggerLevelError` (3)
|
|
28
|
+
*/
|
|
29
|
+
@objc(RNFBAppLogLevelMapper)
|
|
30
|
+
public final class RNFBAppLogLevelMapper: NSObject {
|
|
31
|
+
/// `FIRLoggerLevelError`
|
|
32
|
+
private static let errorLevel = 3
|
|
33
|
+
/// `FIRLoggerLevelWarning`
|
|
34
|
+
private static let warningLevel = 4
|
|
35
|
+
/// `FIRLoggerLevelInfo`
|
|
36
|
+
private static let infoLevel = 6
|
|
37
|
+
/// `FIRLoggerLevelDebug`
|
|
38
|
+
private static let debugLevel = 7
|
|
39
|
+
|
|
40
|
+
@objc(loggerLevelForString:)
|
|
41
|
+
public static func loggerLevel(forString logLevel: String?) -> Int {
|
|
42
|
+
switch logLevel {
|
|
43
|
+
case "verbose", "debug":
|
|
44
|
+
return debugLevel
|
|
45
|
+
case "info":
|
|
46
|
+
return infoLevel
|
|
47
|
+
case "warn":
|
|
48
|
+
return warningLevel
|
|
49
|
+
default:
|
|
50
|
+
return errorLevel
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|