@react-native-firebase/app 26.4.0 → 27.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -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
|
@@ -17,11 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
#import "RNFBHandleMap.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 "RNFBHandleMapStorage Swift interface not found"
|
|
28
|
+
#endif
|
|
29
|
+
|
|
20
30
|
NSErrorDomain const RNFBHandleMapErrorDomain = @"io.invertase.firebase.RNFBHandleMap";
|
|
21
31
|
|
|
22
32
|
@interface RNFBHandleMap ()
|
|
23
|
-
@property(nonatomic, strong)
|
|
24
|
-
@property(nonatomic, strong) NSObject *lock;
|
|
33
|
+
@property(nonatomic, strong) RNFBHandleMapStorage *storage;
|
|
25
34
|
@end
|
|
26
35
|
|
|
27
36
|
@implementation RNFBHandleMap
|
|
@@ -29,88 +38,50 @@ NSErrorDomain const RNFBHandleMapErrorDomain = @"io.invertase.firebase.RNFBHandl
|
|
|
29
38
|
- (instancetype)init {
|
|
30
39
|
self = [super init];
|
|
31
40
|
if (self) {
|
|
32
|
-
|
|
33
|
-
_lock = [[NSObject alloc] init];
|
|
41
|
+
_storage = [[RNFBHandleMapStorage alloc] init];
|
|
34
42
|
}
|
|
35
43
|
return self;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
- (BOOL)put:(id)key value:(id)value error:(NSError **)error {
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
userInfo:@{NSLocalizedDescriptionKey : message}];
|
|
46
|
-
}
|
|
47
|
-
return NO;
|
|
47
|
+
if (![self.storage putIfAbsent:key value:value]) {
|
|
48
|
+
if (error != nil) {
|
|
49
|
+
NSString *message = [NSString stringWithFormat:@"Handle id already registered: %@", key];
|
|
50
|
+
*error = [NSError errorWithDomain:RNFBHandleMapErrorDomain
|
|
51
|
+
code:RNFBHandleMapErrorCollision
|
|
52
|
+
userInfo:@{NSLocalizedDescriptionKey : message}];
|
|
48
53
|
}
|
|
49
|
-
|
|
50
|
-
return YES;
|
|
54
|
+
return NO;
|
|
51
55
|
}
|
|
56
|
+
return YES;
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
- (BOOL)putIfAbsent:(id)key value:(id)value {
|
|
55
|
-
|
|
56
|
-
if (self.map[key] != nil) {
|
|
57
|
-
return NO;
|
|
58
|
-
}
|
|
59
|
-
self.map[key] = value;
|
|
60
|
-
return YES;
|
|
61
|
-
}
|
|
60
|
+
return [self.storage putIfAbsent:key value:value];
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
- (BOOL)putIfAbsentOrSame:(id)key value:(id)value {
|
|
65
|
-
|
|
66
|
-
id existing = self.map[key];
|
|
67
|
-
if (existing == nil) {
|
|
68
|
-
self.map[key] = value;
|
|
69
|
-
return YES;
|
|
70
|
-
}
|
|
71
|
-
return existing == value;
|
|
72
|
-
}
|
|
64
|
+
return [self.storage putIfAbsentOrSame:key value:value];
|
|
73
65
|
}
|
|
74
66
|
|
|
75
67
|
- (id)putReplacing:(id)key value:(id)value {
|
|
76
|
-
|
|
77
|
-
id previous = self.map[key];
|
|
78
|
-
self.map[key] = value;
|
|
79
|
-
return previous;
|
|
80
|
-
}
|
|
68
|
+
return [self.storage putReplacing:key value:value];
|
|
81
69
|
}
|
|
82
70
|
|
|
83
71
|
- (id)get:(id)key {
|
|
84
|
-
|
|
85
|
-
return self.map[key];
|
|
86
|
-
}
|
|
72
|
+
return [self.storage get:key];
|
|
87
73
|
}
|
|
88
74
|
|
|
89
75
|
- (id)take:(id)key {
|
|
90
|
-
|
|
91
|
-
id value = self.map[key];
|
|
92
|
-
[self.map removeObjectForKey:key];
|
|
93
|
-
return value;
|
|
94
|
-
}
|
|
76
|
+
return [self.storage take:key];
|
|
95
77
|
}
|
|
96
78
|
|
|
97
79
|
- (id)takeIf:(id)key when:(BOOL (^)(id))condition {
|
|
98
|
-
|
|
99
|
-
id value = self.map[key];
|
|
100
|
-
if (value != nil && condition(value)) {
|
|
101
|
-
[self.map removeObjectForKey:key];
|
|
102
|
-
return value;
|
|
103
|
-
}
|
|
104
|
-
return nil;
|
|
105
|
-
}
|
|
80
|
+
return [self.storage takeIf:key when:condition];
|
|
106
81
|
}
|
|
107
82
|
|
|
108
83
|
- (NSArray *)takeAll {
|
|
109
|
-
|
|
110
|
-
NSArray *values = [self.map allValues];
|
|
111
|
-
[self.map removeAllObjects];
|
|
112
|
-
return values;
|
|
113
|
-
}
|
|
84
|
+
return [self.storage takeAll];
|
|
114
85
|
}
|
|
115
86
|
|
|
116
87
|
@end
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
@objc(RNFBHandleMapStorage)
|
|
20
|
+
public final class RNFBHandleMapStorage: NSObject {
|
|
21
|
+
private let map = NSMutableDictionary()
|
|
22
|
+
private let lock = NSRecursiveLock()
|
|
23
|
+
|
|
24
|
+
@objc(putIfAbsent:value:)
|
|
25
|
+
public func putIfAbsent(_ key: AnyObject, value: AnyObject) -> Bool {
|
|
26
|
+
lock.withLock {
|
|
27
|
+
guard map.object(forKey: key) == nil else {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
map[key] = value
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@objc(putIfAbsentOrSame:value:)
|
|
36
|
+
public func putIfAbsentOrSame(_ key: AnyObject, value: AnyObject) -> Bool {
|
|
37
|
+
lock.withLock {
|
|
38
|
+
guard let existing = map.object(forKey: key) as AnyObject? else {
|
|
39
|
+
map[key] = value
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
return existing === value
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@objc(putReplacing:value:)
|
|
47
|
+
public func putReplacing(_ key: AnyObject, value: AnyObject) -> AnyObject? {
|
|
48
|
+
lock.withLock {
|
|
49
|
+
let previous = map.object(forKey: key) as AnyObject?
|
|
50
|
+
map[key] = value
|
|
51
|
+
return previous
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@objc(get:)
|
|
56
|
+
public func get(_ key: AnyObject) -> AnyObject? {
|
|
57
|
+
lock.withLock {
|
|
58
|
+
map.object(forKey: key) as AnyObject?
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@objc(take:)
|
|
63
|
+
public func take(_ key: AnyObject) -> AnyObject? {
|
|
64
|
+
lock.withLock {
|
|
65
|
+
let value = map.object(forKey: key) as AnyObject?
|
|
66
|
+
map.removeObject(forKey: key)
|
|
67
|
+
return value
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@objc(takeIf:when:)
|
|
72
|
+
public func takeIf(_ key: AnyObject, when condition: (AnyObject) -> Bool) -> AnyObject? {
|
|
73
|
+
lock.withLock {
|
|
74
|
+
guard let value = map.object(forKey: key) as AnyObject?, condition(value) else {
|
|
75
|
+
return nil
|
|
76
|
+
}
|
|
77
|
+
map.removeObject(forKey: key)
|
|
78
|
+
return value
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@objc
|
|
83
|
+
public func takeAll() -> [AnyObject] {
|
|
84
|
+
lock.withLock {
|
|
85
|
+
let values = map.allValues as [AnyObject]
|
|
86
|
+
map.removeAllObjects()
|
|
87
|
+
return values
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
* Foundation-only normalisation of the `options` and `appConfig` dictionaries passed to
|
|
21
|
+
* `initializeApp`. Decodes `{__rnfbNull: true}` sentinels and drops optional keys whose
|
|
22
|
+
* value is `NSNull` (except `automaticDataCollectionEnabled`, where null means false).
|
|
23
|
+
*/
|
|
24
|
+
@objc(RNFBInitializeAppArguments)
|
|
25
|
+
public final class RNFBInitializeAppArguments: NSObject {
|
|
26
|
+
@objc(normalizedOptions:)
|
|
27
|
+
public static func normalizedOptions(_ options: NSDictionary?) -> NSDictionary? {
|
|
28
|
+
decodedDictionary(
|
|
29
|
+
options,
|
|
30
|
+
optionalKeys: [
|
|
31
|
+
"databaseURL",
|
|
32
|
+
"storageBucket",
|
|
33
|
+
"iosBundleId",
|
|
34
|
+
"iosClientId",
|
|
35
|
+
"appGroupId",
|
|
36
|
+
"authDomain",
|
|
37
|
+
],
|
|
38
|
+
nullReplacements: [:]
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@objc(normalizedAppConfig:)
|
|
43
|
+
public static func normalizedAppConfig(_ appConfig: NSDictionary?) -> NSDictionary? {
|
|
44
|
+
decodedDictionary(
|
|
45
|
+
appConfig,
|
|
46
|
+
optionalKeys: ["name"],
|
|
47
|
+
nullReplacements: ["automaticDataCollectionEnabled": NSNumber(value: false)]
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@objc(automaticDataCollectionEnabledFromAppConfig:)
|
|
52
|
+
public static func automaticDataCollectionEnabled(fromAppConfig appConfig: NSDictionary?) -> NSNumber? {
|
|
53
|
+
guard let value = appConfig?["automaticDataCollectionEnabled"] as? NSNumber else {
|
|
54
|
+
return nil
|
|
55
|
+
}
|
|
56
|
+
return NSNumber(value: value.boolValue)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static func decodedDictionary(
|
|
60
|
+
_ dictionary: NSDictionary?,
|
|
61
|
+
optionalKeys: [String],
|
|
62
|
+
nullReplacements: [String: Any]
|
|
63
|
+
) -> NSDictionary? {
|
|
64
|
+
let decoded = RNFBNullSentinelDecoder.decodeNullSentinels(dictionary)
|
|
65
|
+
guard let decodedDict = decoded as? NSDictionary else {
|
|
66
|
+
return nil
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let normalized = NSMutableDictionary(dictionary: decodedDict)
|
|
70
|
+
for key in optionalKeys {
|
|
71
|
+
if normalized[key] is NSNull {
|
|
72
|
+
normalized.removeObject(forKey: key)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (key, replacement) in nullReplacements {
|
|
76
|
+
if normalized[key] is NSNull {
|
|
77
|
+
normalized[key] = replacement
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return normalized
|
|
81
|
+
}
|
|
82
|
+
}
|
package/ios/RNFBApp/RNFBJSON.m
CHANGED
|
@@ -17,8 +17,18 @@
|
|
|
17
17
|
|
|
18
18
|
#import "RNFBJSON.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 "RNFBJSONImplementation Swift interface not found"
|
|
28
|
+
#endif
|
|
29
|
+
|
|
20
30
|
@interface RNFBJSON ()
|
|
21
|
-
@property(nonatomic, strong)
|
|
31
|
+
@property(nonatomic, strong) RNFBJSONImplementation *implementation;
|
|
22
32
|
@end
|
|
23
33
|
|
|
24
34
|
@implementation RNFBJSON
|
|
@@ -31,69 +41,43 @@
|
|
|
31
41
|
sharedInstance = [[RNFBJSON alloc] init];
|
|
32
42
|
NSString *__nullable firebaseJsonRaw =
|
|
33
43
|
[[NSBundle mainBundle].infoDictionary valueForKey:@"firebase_json_raw"];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sharedInstance.firebaseJson = [NSDictionary dictionary];
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
NSData *data = [[NSData alloc] initWithBase64EncodedString:firebaseJsonRaw options:0];
|
|
41
|
-
|
|
42
|
-
if (data == nil) {
|
|
43
|
-
sharedInstance.firebaseJson = [NSDictionary dictionary];
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
NSError *jsonError = nil;
|
|
48
|
-
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data
|
|
49
|
-
options:0
|
|
50
|
-
error:&jsonError];
|
|
51
|
-
if (jsonError != nil) {
|
|
52
|
-
sharedInstance.firebaseJson = [NSDictionary dictionary];
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
sharedInstance.firebaseJson = dictionary;
|
|
44
|
+
sharedInstance.implementation =
|
|
45
|
+
[[RNFBJSONImplementation alloc] initWithRawValue:firebaseJsonRaw];
|
|
57
46
|
});
|
|
58
47
|
|
|
59
48
|
return sharedInstance;
|
|
60
49
|
}
|
|
61
50
|
|
|
62
51
|
- (BOOL)contains:(NSString *)key {
|
|
63
|
-
return [
|
|
52
|
+
return [self.implementation contains:key];
|
|
64
53
|
}
|
|
65
54
|
|
|
66
55
|
- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue {
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
NSNumber *boolean = [self.implementation valueForKey:key defaultValue:nil];
|
|
57
|
+
if (boolean == nil) return defaultValue;
|
|
69
58
|
return [boolean boolValue];
|
|
70
59
|
}
|
|
71
60
|
|
|
72
61
|
- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue {
|
|
73
|
-
|
|
74
|
-
NSString *string = [_firebaseJson valueForKey:key];
|
|
75
|
-
return string;
|
|
62
|
+
return [self.implementation valueForKey:key defaultValue:defaultValue];
|
|
76
63
|
}
|
|
77
64
|
|
|
78
65
|
- (NSArray *)getArrayValue:(NSString *)key defaultValue:(NSArray *)defaultValue {
|
|
79
|
-
|
|
80
|
-
NSArray *array = [_firebaseJson valueForKey:key];
|
|
81
|
-
return array;
|
|
66
|
+
return [self.implementation valueForKey:key defaultValue:defaultValue];
|
|
82
67
|
}
|
|
83
68
|
|
|
84
69
|
- (NSDictionary *)getAll {
|
|
85
|
-
return [[NSDictionary alloc] initWithDictionary:
|
|
70
|
+
return [[NSDictionary alloc] initWithDictionary:(NSDictionary *)self.implementation.jsonObject
|
|
71
|
+
copyItems:YES];
|
|
86
72
|
}
|
|
87
73
|
|
|
88
74
|
- (NSString *)getRawJSON {
|
|
89
75
|
NSString *__nullable firebaseJsonRaw =
|
|
90
76
|
[[NSBundle mainBundle].infoDictionary valueForKey:@"firebase_json_raw"];
|
|
91
77
|
if (firebaseJsonRaw == nil) {
|
|
92
|
-
return
|
|
78
|
+
return [RNFBJSONImplementation rawJSONFromRawValue:nil];
|
|
93
79
|
}
|
|
94
80
|
|
|
95
|
-
|
|
96
|
-
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
97
|
-
;
|
|
81
|
+
return [RNFBJSONImplementation rawJSONFromRawValue:firebaseJsonRaw];
|
|
98
82
|
}
|
|
99
83
|
@end
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
@objc(RNFBJSONImplementation)
|
|
20
|
+
public final class RNFBJSONImplementation: NSObject {
|
|
21
|
+
private let firebaseJSON: NSObject
|
|
22
|
+
|
|
23
|
+
@objc(initWithRawValue:)
|
|
24
|
+
public init(rawValue: String?) {
|
|
25
|
+
guard
|
|
26
|
+
let rawValue,
|
|
27
|
+
let data = Data(base64Encoded: rawValue),
|
|
28
|
+
let object = try? JSONSerialization.jsonObject(with: data),
|
|
29
|
+
let firebaseJSON = object as? NSObject
|
|
30
|
+
else {
|
|
31
|
+
self.firebaseJSON = NSDictionary()
|
|
32
|
+
super.init()
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
self.firebaseJSON = firebaseJSON
|
|
37
|
+
super.init()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc(initWithJSONObject:)
|
|
41
|
+
public init(jsonObject: NSObject) {
|
|
42
|
+
firebaseJSON = jsonObject
|
|
43
|
+
super.init()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@objc(contains:)
|
|
47
|
+
public func contains(_ key: String) -> Bool {
|
|
48
|
+
firebaseJSON.value(forKey: key) != nil
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@objc(valueForKey:defaultValue:)
|
|
52
|
+
public func value(forKey key: String, defaultValue: AnyObject?) -> AnyObject? {
|
|
53
|
+
firebaseJSON.value(forKey: key) as AnyObject? ?? defaultValue
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@objc
|
|
57
|
+
public func jsonObject() -> NSObject {
|
|
58
|
+
firebaseJSON
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@objc(rawJSONFromRawValue:)
|
|
62
|
+
public static func rawJSON(from rawValue: String?) -> String? {
|
|
63
|
+
guard let rawValue else {
|
|
64
|
+
return "{}"
|
|
65
|
+
}
|
|
66
|
+
guard let data = Data(base64Encoded: rawValue) else {
|
|
67
|
+
return nil
|
|
68
|
+
}
|
|
69
|
+
return String(data: data, encoding: .utf8)
|
|
70
|
+
}
|
|
71
|
+
}
|
package/ios/RNFBApp/RNFBMeta.m
CHANGED
|
@@ -17,45 +17,43 @@
|
|
|
17
17
|
|
|
18
18
|
#import "RNFBMeta.h"
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 "RNFBMetaStorage Swift interface not found"
|
|
28
|
+
#endif
|
|
25
29
|
|
|
26
30
|
@implementation RNFBMeta
|
|
27
31
|
|
|
32
|
+
+ (RNFBMetaStorage *)sharedStorage {
|
|
33
|
+
static dispatch_once_t once;
|
|
34
|
+
static RNFBMetaStorage *sharedStorage;
|
|
35
|
+
|
|
36
|
+
dispatch_once(&once, ^{
|
|
37
|
+
sharedStorage = [[RNFBMetaStorage alloc] init];
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return sharedStorage;
|
|
41
|
+
}
|
|
42
|
+
|
|
28
43
|
+ (BOOL)contains:(NSString *)key {
|
|
29
|
-
|
|
30
|
-
valueForKey:[RNFBMetaPrefix stringByAppendingString:key]];
|
|
31
|
-
return keyValue != nil;
|
|
44
|
+
return [[self sharedStorage] contains:key];
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
+ (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue {
|
|
35
|
-
|
|
36
|
-
valueForKey:[RNFBMetaPrefix stringByAppendingString:key]];
|
|
37
|
-
if (keyValue == nil) return defaultValue;
|
|
38
|
-
return [keyValue boolValue];
|
|
48
|
+
return [[self sharedStorage] getBooleanValue:key defaultValue:defaultValue];
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
+ (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue {
|
|
42
|
-
|
|
43
|
-
valueForKey:[RNFBMetaPrefix stringByAppendingString:key]];
|
|
44
|
-
if (keyValue == nil) return defaultValue;
|
|
45
|
-
return keyValue;
|
|
52
|
+
return [[self sharedStorage] getStringValue:key defaultValue:defaultValue];
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
+ (NSDictionary *)getAll {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
NSArray *keys = [[NSBundle mainBundle].infoDictionary allKeys];
|
|
52
|
-
for (NSString *key in keys) {
|
|
53
|
-
if ([key hasPrefix:RNFBMetaPrefix]) {
|
|
54
|
-
allMetaValues[key] = [NSBundle mainBundle].infoDictionary[key];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return allMetaValues;
|
|
56
|
+
return [[self sharedStorage] getAll];
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
@end
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
private let RNFBMetaPrefix = "rnfirebase_"
|
|
20
|
+
|
|
21
|
+
@objc(RNFBMetaStorage)
|
|
22
|
+
public final class RNFBMetaStorage: NSObject {
|
|
23
|
+
private let infoDictionary: NSDictionary
|
|
24
|
+
|
|
25
|
+
public override convenience init() {
|
|
26
|
+
self.init(infoDictionary: Bundle.main.infoDictionary ?? [:])
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@objc(initWithInfoDictionary:)
|
|
30
|
+
public init(infoDictionary: [String: Any]) {
|
|
31
|
+
self.infoDictionary = infoDictionary as NSDictionary
|
|
32
|
+
super.init()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private func prefixed(_ key: String) -> String {
|
|
36
|
+
RNFBMetaPrefix + key
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@objc(contains:)
|
|
40
|
+
public func contains(_ key: String) -> Bool {
|
|
41
|
+
infoDictionary.value(forKey: prefixed(key)) != nil
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@objc(getBooleanValue:defaultValue:)
|
|
45
|
+
public func getBooleanValue(_ key: String, defaultValue: Bool) -> Bool {
|
|
46
|
+
guard let keyValue = infoDictionary.value(forKey: prefixed(key)) else {
|
|
47
|
+
return defaultValue
|
|
48
|
+
}
|
|
49
|
+
// Pre-port: `[NSNumber boolValue]` after KVC lookup (NSString also responds).
|
|
50
|
+
if let number = keyValue as? NSNumber {
|
|
51
|
+
return number.boolValue
|
|
52
|
+
}
|
|
53
|
+
return (keyValue as! NSString).boolValue
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@objc(getStringValue:defaultValue:)
|
|
57
|
+
public func getStringValue(_ key: String, defaultValue: String) -> String {
|
|
58
|
+
guard let keyValue = infoDictionary.value(forKey: prefixed(key)) else {
|
|
59
|
+
return defaultValue
|
|
60
|
+
}
|
|
61
|
+
// Pre-port returned the unchecked `id` typed as `NSString *`.
|
|
62
|
+
return keyValue as! String
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@objc
|
|
66
|
+
public func getAll() -> [String: Any] {
|
|
67
|
+
var allMetaValues: [String: Any] = [:]
|
|
68
|
+
for key in infoDictionary.allKeys {
|
|
69
|
+
guard let key = key as? String, key.hasPrefix(RNFBMetaPrefix) else {
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
allMetaValues[key] = infoDictionary[key]
|
|
73
|
+
}
|
|
74
|
+
return allMetaValues
|
|
75
|
+
}
|
|
76
|
+
}
|