@react-native-firebase/app 23.8.0 → 23.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +1541 -0
  2. package/RNFBApp.podspec +49 -0
  3. package/android/.editorconfig +10 -0
  4. package/android/build.gradle +129 -0
  5. package/android/firebase-json.gradle +73 -0
  6. package/android/gradle.properties +2 -0
  7. package/android/lint.xml +5 -0
  8. package/android/settings.gradle +1 -0
  9. package/android/src/main/AndroidManifest.xml +24 -0
  10. package/android/src/main/java/io/invertase/firebase/app/.gitkeep +0 -0
  11. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +124 -0
  12. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +62 -0
  13. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +91 -0
  14. package/android/src/main/java/io/invertase/firebase/interfaces/.gitkeep +0 -0
  15. package/android/src/reactnative/AndroidManifest.xml +2 -0
  16. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +46 -0
  17. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppInitProvider.java +22 -0
  18. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppModule.java +186 -0
  19. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +49 -0
  20. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +35 -0
  21. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +22 -0
  22. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +191 -0
  23. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +53 -0
  24. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +151 -0
  25. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseInitProvider.java +78 -0
  26. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +107 -0
  27. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +93 -0
  28. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +146 -0
  29. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +88 -0
  30. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +440 -0
  31. package/android/src/reactnative/java/io/invertase/firebase/interfaces/ContextProvider.java +30 -0
  32. package/android/src/reactnative/java/io/invertase/firebase/interfaces/NativeError.java +32 -0
  33. package/android/src/reactnative/java/io/invertase/firebase/interfaces/NativeEvent.java +28 -0
  34. package/android/src/reactnative/java/io/invertase/firebase/utils/ReactNativeFirebaseUtilsModule.java +191 -0
  35. package/app.plugin.js +1 -0
  36. package/dist/commonjs/version.js +1 -1
  37. package/dist/module/version.js +1 -1
  38. package/dist/typescript/commonjs/lib/modular.d.ts +1 -1
  39. package/dist/typescript/commonjs/lib/version.d.ts +1 -1
  40. package/dist/typescript/module/lib/modular.d.ts +1 -1
  41. package/dist/typescript/module/lib/version.d.ts +1 -1
  42. package/firebase-schema.json +149 -0
  43. package/firebase_json.rb +72 -0
  44. package/ios/RNFBApp/RCTConvert+FIRApp.h +23 -0
  45. package/ios/RNFBApp/RCTConvert+FIRApp.m +31 -0
  46. package/ios/RNFBApp/RCTConvert+FIROptions.h +23 -0
  47. package/ios/RNFBApp/RCTConvert+FIROptions.m +36 -0
  48. package/ios/RNFBApp/RNFBAppModule.h +28 -0
  49. package/ios/RNFBApp/RNFBAppModule.m +305 -0
  50. package/ios/RNFBApp/RNFBJSON.h +36 -0
  51. package/ios/RNFBApp/RNFBJSON.m +99 -0
  52. package/ios/RNFBApp/RNFBMeta.h +30 -0
  53. package/ios/RNFBApp/RNFBMeta.m +61 -0
  54. package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +47 -0
  55. package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +74 -0
  56. package/ios/RNFBApp/RNFBPreferences.h +44 -0
  57. package/ios/RNFBApp/RNFBPreferences.m +94 -0
  58. package/ios/RNFBApp/RNFBRCTEventEmitter.h +73 -0
  59. package/ios/RNFBApp/RNFBRCTEventEmitter.m +151 -0
  60. package/ios/RNFBApp/RNFBSharedUtils.h +67 -0
  61. package/ios/RNFBApp/RNFBSharedUtils.m +285 -0
  62. package/ios/RNFBApp/RNFBUtilsModule.h +30 -0
  63. package/ios/RNFBApp/RNFBUtilsModule.m +100 -0
  64. package/ios/RNFBApp/RNFBVersion.h +20 -0
  65. package/ios/RNFBApp/RNFBVersion.m +21 -0
  66. package/ios/RNFBApp.xcodeproj/project.pbxproj +411 -0
  67. package/ios/RNFBApp.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
  68. package/ios_config.sh +269 -0
  69. package/lib/version.ts +1 -1
  70. package/package.json +3 -10
  71. package/plugin/build/android/applyPlugin.d.ts +6 -0
  72. package/plugin/build/android/applyPlugin.js +29 -0
  73. package/plugin/build/android/buildscriptDependency.d.ts +6 -0
  74. package/plugin/build/android/buildscriptDependency.js +31 -0
  75. package/plugin/build/android/constants.d.ts +4 -0
  76. package/plugin/build/android/constants.js +8 -0
  77. package/plugin/build/android/copyGoogleServices.d.ts +5 -0
  78. package/plugin/build/android/copyGoogleServices.js +33 -0
  79. package/plugin/build/android/index.d.ts +4 -0
  80. package/plugin/build/android/index.js +9 -0
  81. package/plugin/build/index.d.ts +3 -0
  82. package/plugin/build/index.js +21 -0
  83. package/plugin/build/ios/appDelegate.d.ts +6 -0
  84. package/plugin/build/ios/appDelegate.js +116 -0
  85. package/plugin/build/ios/googleServicesPlist.d.ts +7 -0
  86. package/plugin/build/ios/googleServicesPlist.js +42 -0
  87. package/plugin/build/ios/index.d.ts +3 -0
  88. package/plugin/build/ios/index.js +7 -0
  89. package/plugin/src/android/applyPlugin.ts +30 -0
  90. package/plugin/src/android/buildscriptDependency.ts +33 -0
  91. package/plugin/src/android/constants.ts +7 -0
  92. package/plugin/src/android/copyGoogleServices.ts +36 -0
  93. package/plugin/src/android/index.ts +5 -0
  94. package/plugin/src/index.ts +27 -0
  95. package/plugin/src/ios/appDelegate.ts +140 -0
  96. package/plugin/src/ios/googleServicesPlist.ts +55 -0
  97. package/plugin/src/ios/index.ts +4 -0
  98. package/plugin/tsconfig.json +9 -0
  99. package/plugin/tsconfig.tsbuildinfo +1 -0
  100. package/react-native.config.js +19 -0
  101. package/tsconfig.json +10 -0
@@ -0,0 +1,305 @@
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
+
18
+ #import <Firebase/Firebase.h>
19
+ #import <React/RCTUtils.h>
20
+
21
+ #import "RNFBAppModule.h"
22
+ #import "RNFBJSON.h"
23
+ #import "RNFBMeta.h"
24
+ #import "RNFBPreferences.h"
25
+ #import "RNFBRCTEventEmitter.h"
26
+ #import "RNFBSharedUtils.h"
27
+ #import "RNFBVersion.h"
28
+
29
+ #if __has_include(<FirebaseCore/FIRAppInternal.h>)
30
+ #import <FirebaseCore/FIRAppInternal.h>
31
+ #define REGISTER_LIB
32
+ #endif
33
+
34
+ @implementation RNFBAppModule
35
+
36
+ #pragma mark -
37
+ #pragma mark Module Setup
38
+
39
+ RCT_EXPORT_MODULE();
40
+
41
+ - (dispatch_queue_t)methodQueue {
42
+ return dispatch_get_main_queue();
43
+ }
44
+
45
+ - (void)setBridge:(RCTBridge *)bridge {
46
+ [RNFBRCTEventEmitter shared].bridge = bridge;
47
+ }
48
+
49
+ - (RCTBridge *)bridge {
50
+ return [RNFBRCTEventEmitter shared].bridge;
51
+ }
52
+
53
+ - (id)init {
54
+ if (self = [super init]) {
55
+ #ifdef REGISTER_LIB
56
+ static dispatch_once_t once;
57
+ dispatch_once(&once, ^{
58
+ [FIRApp registerLibrary:@"react-native-firebase" withVersion:[RNFBVersionString copy]];
59
+ });
60
+ #endif
61
+ if ([[RNFBJSON shared] contains:@"app_log_level"]) {
62
+ NSString *logLevel = [[RNFBJSON shared] getStringValue:@"app_log_level" defaultValue:@"info"];
63
+ [self setLogLevel:logLevel];
64
+ }
65
+ }
66
+
67
+ return self;
68
+ }
69
+
70
+ - (void)invalidate {
71
+ [[RNFBRCTEventEmitter shared] invalidate];
72
+ }
73
+
74
+ #pragma mark -
75
+ #pragma mark META Methods
76
+
77
+ RCT_EXPORT_METHOD(metaGetAll
78
+ : (RCTPromiseResolveBlock)resolve rejecter
79
+ : (RCTPromiseRejectBlock)reject) {
80
+ resolve([RNFBMeta getAll]);
81
+ }
82
+
83
+ #pragma mark -
84
+ #pragma mark JSON Methods
85
+
86
+ RCT_EXPORT_METHOD(jsonGetAll
87
+ : (RCTPromiseResolveBlock)resolve rejecter
88
+ : (RCTPromiseRejectBlock)reject) {
89
+ resolve([[RNFBJSON shared] getAll]);
90
+ }
91
+
92
+ #pragma mark -
93
+ #pragma mark Preference Methods
94
+
95
+ RCT_EXPORT_METHOD(preferencesSetBool
96
+ : (NSString *)key boolValue
97
+ : (BOOL)boolValue resolver
98
+ : (RCTPromiseResolveBlock)resolve rejecter
99
+ : (RCTPromiseRejectBlock)reject) {
100
+ [[RNFBPreferences shared] setBooleanValue:key boolValue:boolValue];
101
+ resolve([NSNull null]);
102
+ }
103
+
104
+ RCT_EXPORT_METHOD(preferencesSetString
105
+ : (NSString *)key stringValue
106
+ : (NSString *)stringValue resolver
107
+ : (RCTPromiseResolveBlock)resolve rejecter
108
+ : (RCTPromiseRejectBlock)reject) {
109
+ [[RNFBPreferences shared] setStringValue:key stringValue:stringValue];
110
+ resolve([NSNull null]);
111
+ }
112
+
113
+ RCT_EXPORT_METHOD(preferencesGetAll
114
+ : (RCTPromiseResolveBlock)resolve rejecter
115
+ : (RCTPromiseRejectBlock)reject) {
116
+ resolve([[RNFBPreferences shared] getAll]);
117
+ }
118
+
119
+ RCT_EXPORT_METHOD(preferencesClearAll
120
+ : (RCTPromiseResolveBlock)resolve rejecter
121
+ : (RCTPromiseRejectBlock)reject) {
122
+ [[RNFBPreferences shared] clearAll];
123
+ resolve([NSNull null]);
124
+ }
125
+
126
+ #pragma mark -
127
+ #pragma mark Event Methods
128
+
129
+ RCT_EXPORT_METHOD(eventsNotifyReady : (BOOL)ready) {
130
+ [[RNFBRCTEventEmitter shared] notifyJsReady:ready];
131
+ }
132
+
133
+ RCT_EXPORT_METHOD(eventsGetListeners
134
+ : (RCTPromiseResolveBlock)resolve rejecter
135
+ : (RCTPromiseRejectBlock)reject) {
136
+ resolve([[RNFBRCTEventEmitter shared] getListenersDictionary]);
137
+ }
138
+
139
+ RCT_EXPORT_METHOD(eventsPing
140
+ : (NSString *)eventName eventBody
141
+ : (NSDictionary *)eventBody resolver
142
+ : (RCTPromiseResolveBlock)resolve rejecter
143
+ : (RCTPromiseRejectBlock)reject) {
144
+ [[RNFBRCTEventEmitter shared] sendEventWithName:eventName body:eventBody];
145
+ resolve(eventBody);
146
+ }
147
+
148
+ RCT_EXPORT_METHOD(eventsAddListener : (NSString *)eventName) {
149
+ [[RNFBRCTEventEmitter shared] addListener:eventName];
150
+ }
151
+
152
+ RCT_EXPORT_METHOD(eventsRemoveListener : (NSString *)eventName all : (BOOL)all) {
153
+ [[RNFBRCTEventEmitter shared] removeListeners:eventName all:all];
154
+ }
155
+
156
+ #pragma mark -
157
+ #pragma mark Events Unused
158
+
159
+ RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
160
+ // Keep: Required for RN built in Event Emitter Calls.
161
+ }
162
+
163
+ RCT_EXPORT_METHOD(removeListeners : (NSInteger)count) {
164
+ // Keep: Required for RN built in Event Emitter Calls.
165
+ }
166
+
167
+ #pragma mark -
168
+ #pragma mark Firebase App Methods
169
+
170
+ RCT_EXPORT_METHOD(initializeApp
171
+ : (NSDictionary *)options appConfig
172
+ : (NSDictionary *)appConfig resolver
173
+ : (RCTPromiseResolveBlock)resolve rejecter
174
+ : (RCTPromiseRejectBlock)reject) {
175
+ RCTUnsafeExecuteOnMainQueueSync(^{
176
+ FIRApp *firApp;
177
+ NSString *appName = [appConfig valueForKey:@"name"];
178
+
179
+ NSString *appId = [options valueForKey:@"appId"];
180
+ NSString *messagingSenderId = [options valueForKey:@"messagingSenderId"];
181
+ FIROptions *firOptions = [[FIROptions alloc] initWithGoogleAppID:appId
182
+ GCMSenderID:messagingSenderId];
183
+ firOptions.APIKey = [options valueForKey:@"apiKey"];
184
+ firOptions.projectID = [options valueForKey:@"projectId"];
185
+ // kFirebaseOptionsDatabaseUrl
186
+ if (![[options valueForKey:@"databaseURL"] isEqual:[NSNull null]]) {
187
+ firOptions.databaseURL = [options valueForKey:@"databaseURL"];
188
+ }
189
+ // kFirebaseOptionsStorageBucket
190
+ if (![[options valueForKey:@"storageBucket"] isEqual:[NSNull null]]) {
191
+ firOptions.storageBucket = [options valueForKey:@"storageBucket"];
192
+ }
193
+
194
+ // kFirebaseOptionsIosBundleId
195
+ if (![[options valueForKey:@"iosBundleId"] isEqual:[NSNull null]]) {
196
+ firOptions.bundleID = [options valueForKey:@"iosBundleId"];
197
+ }
198
+ // kFirebaseOptionsIosClientId
199
+ if (![[options valueForKey:@"iosClientId"] isEqual:[NSNull null]]) {
200
+ firOptions.clientID = [options valueForKey:@"iosClientId"];
201
+ }
202
+ // kFirebaseOptionsAppGroupId
203
+ if (![[options valueForKey:@"appGroupId"] isEqual:[NSNull null]]) {
204
+ firOptions.appGroupID = [options valueForKey:@"appGroupId"];
205
+ }
206
+
207
+ if ([options valueForKey:@"authDomain"] != nil) {
208
+ DLog(@"RNFBAuth app: %@ customAuthDomain: %@", appName, [options valueForKey:@"authDomain"]);
209
+ if (customAuthDomains == nil) {
210
+ customAuthDomains = [[NSMutableDictionary alloc] init];
211
+ }
212
+ customAuthDomains[appName] = [options valueForKey:@"authDomain"];
213
+ }
214
+ @try {
215
+ if (!appName || [appName isEqualToString:DEFAULT_APP_DISPLAY_NAME]) {
216
+ [FIRApp configureWithOptions:firOptions];
217
+ firApp = [FIRApp defaultApp];
218
+ } else {
219
+ [FIRApp configureWithName:appName options:firOptions];
220
+ firApp = [FIRApp appNamed:appName];
221
+ }
222
+ } @catch (NSException *exception) {
223
+ return [RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:exception];
224
+ }
225
+
226
+ firApp.dataCollectionDefaultEnabled =
227
+ (BOOL)[appConfig valueForKey:@"automaticDataCollectionEnabled"];
228
+
229
+ resolve([RNFBSharedUtils firAppToDictionary:firApp]);
230
+ });
231
+ }
232
+
233
+ static NSMutableDictionary<NSString *, NSString *> *customAuthDomains;
234
+
235
+ + (NSString *)getCustomDomain:(NSString *)appName {
236
+ DLog(@"authDomains: %@", customAuthDomains);
237
+ return customAuthDomains[appName];
238
+ }
239
+
240
+ RCT_EXPORT_METHOD(setLogLevel : (NSString *)logLevel) {
241
+ int level = FIRLoggerLevelError;
242
+ if ([logLevel isEqualToString:@"verbose"]) {
243
+ level = FIRLoggerLevelDebug;
244
+ } else if ([logLevel isEqualToString:@"debug"]) {
245
+ level = FIRLoggerLevelDebug;
246
+ } else if ([logLevel isEqualToString:@"info"]) {
247
+ level = FIRLoggerLevelInfo;
248
+ } else if ([logLevel isEqualToString:@"warn"]) {
249
+ level = FIRLoggerLevelWarning;
250
+ }
251
+ DLog(@"RNFBSetLogLevel: setting level to %d from %@.", level, logLevel);
252
+ [[FIRConfiguration sharedInstance] setLoggerLevel:level];
253
+ }
254
+
255
+ RCT_EXPORT_METHOD(setAutomaticDataCollectionEnabled : (FIRApp *)firApp enabled : (BOOL)enabled) {
256
+ if (firApp) {
257
+ firApp.dataCollectionDefaultEnabled = enabled;
258
+ }
259
+ }
260
+
261
+ RCT_EXPORT_METHOD(deleteApp
262
+ : (FIRApp *)firApp resolver
263
+ : (RCTPromiseResolveBlock)resolve rejecter
264
+ : (RCTPromiseRejectBlock)reject) {
265
+ if (!firApp) {
266
+ return resolve([NSNull null]);
267
+ }
268
+
269
+ [firApp deleteApp:^(BOOL success) {
270
+ if (success) {
271
+ resolve([NSNull null]);
272
+ } else {
273
+ // try again once more
274
+ [firApp deleteApp:^(BOOL success2) {
275
+ if (success2) {
276
+ resolve([NSNull null]);
277
+ } else {
278
+ // TODO js error builder
279
+ reject(@"app/delete-app-failed", @"Failed to delete the specified app.", nil);
280
+ }
281
+ }];
282
+ }
283
+ }];
284
+ }
285
+
286
+ - (NSDictionary *)constantsToExport {
287
+ NSDictionary *firApps = [FIRApp allApps];
288
+ NSMutableArray *appsArray = [NSMutableArray new];
289
+ NSMutableDictionary *constants = [NSMutableDictionary new];
290
+
291
+ for (id key in firApps) {
292
+ [appsArray addObject:[RNFBSharedUtils firAppToDictionary:firApps[key]]];
293
+ }
294
+
295
+ constants[@"NATIVE_FIREBASE_APPS"] = appsArray;
296
+
297
+ constants[@"FIREBASE_RAW_JSON"] = [[RNFBJSON shared] getRawJSON];
298
+
299
+ return constants;
300
+ }
301
+
302
+ + (BOOL)requiresMainQueueSetup {
303
+ return YES;
304
+ }
305
+ @end
@@ -0,0 +1,36 @@
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
+
18
+ #import <Foundation/Foundation.h>
19
+
20
+ @interface RNFBJSON : NSObject
21
+
22
+ - (BOOL)contains:(NSString *)key;
23
+
24
+ - (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue;
25
+
26
+ - (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue;
27
+
28
+ - (NSArray *)getArrayValue:(NSString *)key defaultValue:(NSArray *)defaultValue;
29
+
30
+ - (NSDictionary *)getAll;
31
+
32
+ - (NSString *)getRawJSON;
33
+
34
+ + (RNFBJSON *)shared;
35
+
36
+ @end
@@ -0,0 +1,99 @@
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
+
18
+ #import "RNFBJSON.h"
19
+
20
+ @interface RNFBJSON ()
21
+ @property(nonatomic, strong) NSDictionary *firebaseJson;
22
+ @end
23
+
24
+ @implementation RNFBJSON
25
+
26
+ + (instancetype)shared {
27
+ static dispatch_once_t once;
28
+ static RNFBJSON *sharedInstance;
29
+
30
+ dispatch_once(&once, ^{
31
+ sharedInstance = [[RNFBJSON alloc] init];
32
+ NSString *__nullable firebaseJsonRaw =
33
+ [[NSBundle mainBundle].infoDictionary valueForKey:@"firebase_json_raw"];
34
+
35
+ if (firebaseJsonRaw == nil) {
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;
57
+ });
58
+
59
+ return sharedInstance;
60
+ }
61
+
62
+ - (BOOL)contains:(NSString *)key {
63
+ return [_firebaseJson valueForKey:key] != nil;
64
+ }
65
+
66
+ - (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue {
67
+ if ([_firebaseJson valueForKey:key] == nil) return defaultValue;
68
+ NSNumber *boolean = [_firebaseJson valueForKey:key];
69
+ return [boolean boolValue];
70
+ }
71
+
72
+ - (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue {
73
+ if ([_firebaseJson valueForKey:key] == nil) return defaultValue;
74
+ NSString *string = [_firebaseJson valueForKey:key];
75
+ return string;
76
+ }
77
+
78
+ - (NSArray *)getArrayValue:(NSString *)key defaultValue:(NSArray *)defaultValue {
79
+ if ([_firebaseJson valueForKey:key] == nil) return defaultValue;
80
+ NSArray *array = [_firebaseJson valueForKey:key];
81
+ return array;
82
+ }
83
+
84
+ - (NSDictionary *)getAll {
85
+ return [[NSDictionary alloc] initWithDictionary:_firebaseJson copyItems:YES];
86
+ }
87
+
88
+ - (NSString *)getRawJSON {
89
+ NSString *__nullable firebaseJsonRaw =
90
+ [[NSBundle mainBundle].infoDictionary valueForKey:@"firebase_json_raw"];
91
+ if (firebaseJsonRaw == nil) {
92
+ return @"{}";
93
+ }
94
+
95
+ NSData *data = [[NSData alloc] initWithBase64EncodedString:firebaseJsonRaw options:0];
96
+ return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
97
+ ;
98
+ }
99
+ @end
@@ -0,0 +1,30 @@
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
+
18
+ #import <Foundation/Foundation.h>
19
+
20
+ @interface RNFBMeta : NSObject
21
+
22
+ + (BOOL)contains:(NSString *)key;
23
+
24
+ + (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue;
25
+
26
+ + (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue;
27
+
28
+ + (NSDictionary *)getAll;
29
+
30
+ @end
@@ -0,0 +1,61 @@
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
+
18
+ #import "RNFBMeta.h"
19
+
20
+ @interface RNFBMeta ()
21
+ @property(nonatomic, strong) NSDictionary *firebaseJson;
22
+ @end
23
+
24
+ NSString *const RNFBMetaPrefix = @"rnfirebase_";
25
+
26
+ @implementation RNFBMeta
27
+
28
+ + (BOOL)contains:(NSString *)key {
29
+ id keyValue = [[NSBundle mainBundle].infoDictionary
30
+ valueForKey:[RNFBMetaPrefix stringByAppendingString:key]];
31
+ return keyValue != nil;
32
+ }
33
+
34
+ + (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue {
35
+ NSNumber *keyValue = [[NSBundle mainBundle].infoDictionary
36
+ valueForKey:[RNFBMetaPrefix stringByAppendingString:key]];
37
+ if (keyValue == nil) return defaultValue;
38
+ return [keyValue boolValue];
39
+ }
40
+
41
+ + (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue {
42
+ NSString *keyValue = [[NSBundle mainBundle].infoDictionary
43
+ valueForKey:[RNFBMetaPrefix stringByAppendingString:key]];
44
+ if (keyValue == nil) return defaultValue;
45
+ return keyValue;
46
+ }
47
+
48
+ + (NSDictionary *)getAll {
49
+ NSMutableDictionary *allMetaValues = [NSMutableDictionary dictionary];
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;
59
+ }
60
+
61
+ @end
@@ -0,0 +1,47 @@
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
+
18
+ #ifndef RNFBNullSentinelInterceptor_h
19
+ #define RNFBNullSentinelInterceptor_h
20
+
21
+ #import <Foundation/Foundation.h>
22
+
23
+ /**
24
+ * Intercepts TurboModule conversions to automatically decode null sentinels.
25
+ *
26
+ * iOS TurboModules strip null values from object properties during serialization.
27
+ * See: https://github.com/facebook/react-native/issues/52802
28
+ * The JavaScript side encodes nulls as sentinel objects,
29
+ * and this interceptor automatically converts them back to NSNull before they
30
+ * reach module implementation methods.
31
+ *
32
+ * This class uses method swizzling on RCTCxxConvert to intercept all TurboModule
33
+ * data conversion methods (JS_*Module_Spec*Data:), decoding sentinels before the
34
+ * data reaches the C++ bridging layer and ultimately your module methods.
35
+ */
36
+ @interface RNFBNullSentinelInterceptor : NSObject
37
+
38
+ /**
39
+ * Initializes the null sentinel interceptor.
40
+ * This swizzles RCTCxxConvert (TurboModule converter) to automatically decode null sentinels.
41
+ * Called automatically when the class is loaded via +load.
42
+ */
43
+ + (void)initialize;
44
+
45
+ @end
46
+
47
+ #endif
@@ -0,0 +1,74 @@
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
+
18
+ #import "RNFBNullSentinelInterceptor.h"
19
+ #import <objc/runtime.h>
20
+ #import "RNFBSharedUtils.h"
21
+
22
+ @implementation RNFBNullSentinelInterceptor
23
+
24
+ + (void)load {
25
+ static dispatch_once_t onceToken;
26
+ dispatch_once(&onceToken, ^{
27
+ [self swizzleRCTConvertMethods];
28
+ });
29
+ }
30
+
31
+ + (void)swizzleRCTConvertMethods {
32
+ // For TurboModules: Swizzle RCTCxxConvert to intercept all conversion methods
33
+ Class cxxConvertClass = NSClassFromString(@"RCTCxxConvert");
34
+ if (cxxConvertClass) {
35
+ [self swizzleTurboModuleConversions:cxxConvertClass];
36
+ }
37
+ }
38
+
39
+ + (void)swizzleTurboModuleConversions:(Class)cxxConvertClass {
40
+ // Get all methods from RCTCxxConvert
41
+ unsigned int methodCount = 0;
42
+ Method *methods = class_copyMethodList(object_getClass(cxxConvertClass), &methodCount);
43
+
44
+ for (unsigned int i = 0; i < methodCount; i++) {
45
+ Method method = methods[i];
46
+ SEL selector = method_getName(method);
47
+ NSString *selectorName = NSStringFromSelector(selector);
48
+
49
+ // Intercept TurboModule data conversion methods (they follow pattern:
50
+ // JS_NativeRNFBTurbo*_Spec*)
51
+ if ([selectorName hasPrefix:@"JS_NativeRNFBTurbo"] && [selectorName containsString:@"_Spec"]) {
52
+ // Create a swizzled version using IMP
53
+ IMP originalIMP = method_getImplementation(method);
54
+ const char *typeEncoding = method_getTypeEncoding(method);
55
+
56
+ // Replace with our wrapper that decodes nulls
57
+ IMP newIMP = imp_implementationWithBlock(^id(id self, id json) {
58
+ // Decode null sentinels before passing to original conversion
59
+ id decoded = [RNFBSharedUtils decodeNullSentinels:json];
60
+
61
+ // Call original implementation with decoded data
62
+ typedef id (*OriginalFunc)(id, SEL, id);
63
+ OriginalFunc originalFunc = (OriginalFunc)originalIMP;
64
+ return originalFunc(self, selector, decoded);
65
+ });
66
+
67
+ method_setImplementation(method, newIMP);
68
+ }
69
+ }
70
+
71
+ free(methods);
72
+ }
73
+
74
+ @end
@@ -0,0 +1,44 @@
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
+
18
+ #import <Foundation/Foundation.h>
19
+
20
+ @interface RNFBPreferences : NSObject
21
+
22
+ - (BOOL)contains:(NSString *)key;
23
+
24
+ - (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue;
25
+
26
+ - (void)setBooleanValue:(NSString *)key boolValue:(BOOL)boolValue;
27
+
28
+ - (void)setIntegerValue:(NSString *)key integerValue:(NSInteger)integerValue;
29
+
30
+ - (void)setStringValue:(NSString *)key stringValue:(NSString *)stringValue;
31
+
32
+ - (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue;
33
+
34
+ - (NSInteger)getIntegerValue:(NSString *)key defaultValue:(NSInteger)defaultValue;
35
+
36
+ - (NSDictionary *)getAll;
37
+
38
+ - (void)clearAll;
39
+
40
+ - (void)remove:(NSString *)key;
41
+
42
+ + (RNFBPreferences *)shared;
43
+
44
+ @end