react-native-rook-sdk 0.7.0 → 1.0.0-rc.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.
- package/android/src/main/java/com/rooksdk/RookSdkModule.kt +51 -597
- package/android/src/main/java/com/rooksdk/RookSdkPackage.kt +17 -1
- package/android/src/main/java/com/rooksdk/broadcasts/AndroidPermissionsReceiverTransmitter.kt +18 -0
- package/android/src/main/java/com/rooksdk/broadcasts/HealthConnectPermissionsReceiverTransmitter.kt +18 -0
- package/android/src/main/java/com/rooksdk/modules/RookConfigurationModule.kt +108 -0
- package/android/src/main/java/com/rooksdk/modules/RookPermissionsModule.kt +160 -0
- package/android/src/main/java/com/rooksdk/modules/RookStepsModule.kt +105 -0
- package/android/src/main/java/com/rooksdk/modules/RookSyncModule.kt +497 -0
- package/android/src/main/java/com/rooksdk/utils/DatasourcesUtils.kt +49 -0
- package/android/src/main/java/com/rooksdk/utils/ReadableToWritable.kt +20 -0
- package/android/src/main/java/com/rooksdk/utils/RookDateTime.kt +8 -0
- package/ios/RookSdk.mm +296 -8
- package/lib/commonjs/context/RookSyncGateContext.js +12 -0
- package/lib/commonjs/context/RookSyncGateContext.js.map +1 -1
- package/lib/commonjs/context/RookSyncGateProvider.js +12 -5
- package/lib/commonjs/context/RookSyncGateProvider.js.map +1 -1
- package/lib/commonjs/context/RookSyncGateReducer.js +15 -0
- package/lib/commonjs/context/RookSyncGateReducer.js.map +1 -1
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js +26 -41
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
- package/lib/commonjs/hooks/useRookAppleHealth.js +24 -10
- package/lib/commonjs/hooks/useRookAppleHealth.js.map +1 -1
- package/lib/commonjs/hooks/useRookAppleHealthVariables.js +22 -4
- package/lib/commonjs/hooks/useRookAppleHealthVariables.js.map +1 -1
- package/lib/commonjs/hooks/useRookConfiguration.js +32 -16
- package/lib/commonjs/hooks/useRookConfiguration.js.map +1 -1
- package/lib/commonjs/hooks/useRookDataSources.js +18 -5
- package/lib/commonjs/hooks/useRookDataSources.js.map +1 -1
- package/lib/commonjs/hooks/useRookEvents.js +61 -57
- package/lib/commonjs/hooks/useRookEvents.js.map +1 -1
- package/lib/commonjs/hooks/useRookPermissions.js +59 -28
- package/lib/commonjs/hooks/useRookPermissions.js.map +1 -1
- package/lib/commonjs/hooks/useRookSummaries.js +23 -30
- package/lib/commonjs/hooks/useRookSummaries.js.map +1 -1
- package/lib/commonjs/modules/hook/useRookAutoSync.js +100 -32
- package/lib/commonjs/modules/hook/useRookAutoSync.js.map +1 -1
- package/lib/commonjs/types/PermissionsType.js +2 -0
- package/lib/commonjs/types/PermissionsType.js.map +1 -0
- package/lib/commonjs/utils/getNativeModule.js +29 -0
- package/lib/commonjs/utils/getNativeModule.js.map +1 -0
- package/lib/commonjs/utils/getRookModule.js +7 -0
- package/lib/commonjs/utils/getRookModule.js.map +1 -1
- package/lib/commonjs/utils/isModuleReady.js +6 -0
- package/lib/commonjs/utils/isModuleReady.js.map +1 -1
- package/lib/commonjs/utils/isValidDate.js +6 -0
- package/lib/commonjs/utils/isValidDate.js.map +1 -1
- package/lib/commonjs/utils/nativeModules.js +19 -0
- package/lib/commonjs/utils/nativeModules.js.map +1 -0
- package/lib/module/context/RookSyncGateContext.js +12 -0
- package/lib/module/context/RookSyncGateContext.js.map +1 -1
- package/lib/module/context/RookSyncGateProvider.js +8 -1
- package/lib/module/context/RookSyncGateProvider.js.map +1 -1
- package/lib/module/context/RookSyncGateReducer.js +15 -0
- package/lib/module/context/RookSyncGateReducer.js.map +1 -1
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js +14 -29
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
- package/lib/module/hooks/useRookAppleHealth.js +15 -2
- package/lib/module/hooks/useRookAppleHealth.js.map +1 -1
- package/lib/module/hooks/useRookAppleHealthVariables.js +20 -2
- package/lib/module/hooks/useRookAppleHealthVariables.js.map +1 -1
- package/lib/module/hooks/useRookConfiguration.js +18 -3
- package/lib/module/hooks/useRookConfiguration.js.map +1 -1
- package/lib/module/hooks/useRookDataSources.js +14 -2
- package/lib/module/hooks/useRookDataSources.js.map +1 -1
- package/lib/module/hooks/useRookEvents.js +32 -28
- package/lib/module/hooks/useRookEvents.js.map +1 -1
- package/lib/module/hooks/useRookPermissions.js +39 -9
- package/lib/module/hooks/useRookPermissions.js.map +1 -1
- package/lib/module/hooks/useRookSummaries.js +16 -23
- package/lib/module/hooks/useRookSummaries.js.map +1 -1
- package/lib/module/modules/hook/useRookAutoSync.js +100 -33
- package/lib/module/modules/hook/useRookAutoSync.js.map +1 -1
- package/lib/module/types/PermissionsType.js +2 -0
- package/lib/module/types/PermissionsType.js.map +1 -0
- package/lib/module/utils/getNativeModule.js +23 -0
- package/lib/module/utils/getNativeModule.js.map +1 -0
- package/lib/module/utils/getRookModule.js +8 -0
- package/lib/module/utils/getRookModule.js.map +1 -1
- package/lib/module/utils/isModuleReady.js +6 -0
- package/lib/module/utils/isModuleReady.js.map +1 -1
- package/lib/module/utils/isValidDate.js +6 -0
- package/lib/module/utils/isValidDate.js.map +1 -1
- package/lib/module/utils/nativeModules.js +13 -0
- package/lib/module/utils/nativeModules.js.map +1 -0
- package/lib/typescript/src/context/RookSyncGateContext.d.ts +7 -0
- package/lib/typescript/src/context/RookSyncGateContext.d.ts.map +1 -1
- package/lib/typescript/src/context/RookSyncGateProvider.d.ts.map +1 -1
- package/lib/typescript/src/context/RookSyncGateReducer.d.ts +15 -0
- package/lib/typescript/src/context/RookSyncGateReducer.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts +6 -2
- package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAppleHealth.d.ts +1 -1
- package/lib/typescript/src/hooks/useRookAppleHealth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAppleHealthVariables.d.ts +9 -0
- package/lib/typescript/src/hooks/useRookAppleHealthVariables.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts +6 -0
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookDataSources.d.ts +6 -0
- package/lib/typescript/src/hooks/useRookDataSources.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookEvents.d.ts +9 -1
- package/lib/typescript/src/hooks/useRookEvents.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookPermissions.d.ts +10 -0
- package/lib/typescript/src/hooks/useRookPermissions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookSummaries.d.ts +6 -6
- package/lib/typescript/src/hooks/useRookSummaries.d.ts.map +1 -1
- package/lib/typescript/src/modules/hook/useRookAutoSync.d.ts +16 -0
- package/lib/typescript/src/modules/hook/useRookAutoSync.d.ts.map +1 -1
- package/lib/typescript/src/types/PermissionsType.d.ts +6 -0
- package/lib/typescript/src/types/PermissionsType.d.ts.map +1 -0
- package/lib/typescript/src/utils/getNativeModule.d.ts +10 -0
- package/lib/typescript/src/utils/getNativeModule.d.ts.map +1 -0
- package/lib/typescript/src/utils/getRookModule.d.ts +7 -0
- package/lib/typescript/src/utils/getRookModule.d.ts.map +1 -1
- package/lib/typescript/src/utils/isModuleReady.d.ts +6 -0
- package/lib/typescript/src/utils/isModuleReady.d.ts.map +1 -1
- package/lib/typescript/src/utils/isValidDate.d.ts +6 -0
- package/lib/typescript/src/utils/isValidDate.d.ts.map +1 -1
- package/lib/typescript/src/utils/nativeModules.d.ts +14 -0
- package/lib/typescript/src/utils/nativeModules.d.ts.map +1 -0
- package/package.json +1 -1
- package/react-native-rook-sdk.podspec +1 -1
- package/lib/commonjs/utils/index.js +0 -69
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/module/utils/index.js +0 -9
- package/lib/module/utils/index.js.map +0 -1
- package/lib/typescript/src/utils/index.d.ts +0 -9
- package/lib/typescript/src/utils/index.d.ts.map +0 -1
package/ios/RookSdk.mm
CHANGED
|
@@ -11,6 +11,10 @@ NSString *convertToString(id value) {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// The above code is a function that takes a string representing a date in the
|
|
15
|
+
// format "yyyy-MM-dd" as input. It creates an instance of NSDateFormatter, sets the date format to
|
|
16
|
+
// "yyyy-MM-dd", and then uses the date formatter to convert the input string into an NSDate object
|
|
17
|
+
// representing the parsed date. Finally, it returns the parsed NSDate object.
|
|
14
18
|
NSDate *parseDateFromString(NSString * dateString) {
|
|
15
19
|
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
|
16
20
|
|
|
@@ -21,6 +25,11 @@ NSDate *parseDateFromString(NSString * dateString) {
|
|
|
21
25
|
return date;
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
// A function that takes an NSException object as input and creates an
|
|
29
|
+
// NSError object based on the exception information. It creates a dictionary with localized
|
|
30
|
+
// description and failure reason keys using the exception's name and reason properties. Then, it
|
|
31
|
+
// creates an NSError object with a custom domain, error code, and the dictionary of error information,
|
|
32
|
+
// and returns it.
|
|
24
33
|
NSError *errorFromException(NSException *exception) {
|
|
25
34
|
NSMutableDictionary *errorInfo = [NSMutableDictionary dictionary];
|
|
26
35
|
errorInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Exception caught: %@", exception.name];
|
|
@@ -40,6 +49,8 @@ RCT_EXPORT_MODULE()
|
|
|
40
49
|
-(void)startObserving {
|
|
41
50
|
hasListeners = YES;
|
|
42
51
|
|
|
52
|
+
NSLog(@"Hay alguien escuchando");
|
|
53
|
+
|
|
43
54
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
44
55
|
selector:@selector(receiveTestNotification:)
|
|
45
56
|
name:@"kRookErrorBackground"
|
|
@@ -57,19 +68,23 @@ RCT_EXPORT_MODULE()
|
|
|
57
68
|
return @[@"ROOK_NOTIFICATION"];
|
|
58
69
|
}
|
|
59
70
|
|
|
71
|
+
// The above code is an Objective-C method that receives a notification and checks if the notification
|
|
72
|
+
// name is "kRookErrorBackground". If it is, it extracts information from the notification's userInfo
|
|
73
|
+
// dictionary, specifically an error object. It then creates a dictionary message containing the type,
|
|
74
|
+
// message, and code extracted from the error object. Finally, if there are listeners registered, it
|
|
75
|
+
// sends an event with the message dictionary to a specific event name "ROOK_NOTIFICATION".
|
|
60
76
|
- (void) receiveTestNotification:(NSNotification *) notification
|
|
61
77
|
{
|
|
62
78
|
if ([[notification name] isEqualToString:@"kRookErrorBackground"]) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
for(NSString *key in [notificationInfo allKeys]) {
|
|
66
|
-
NSLog(@"%@",[notificationInfo objectForKey:key]);
|
|
67
|
-
}
|
|
79
|
+
NSDictionary<NSString*, NSError *> *notificationInfo = [[notification userInfo] mutableCopy];
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
NSMutableDictionary *message = [[NSMutableDictionary alloc] init];
|
|
82
|
+
message[@"type"] = @"ROOK_APPLE_HEALTH_BACKGROUND_ERROR";
|
|
83
|
+
message[@"message"] = notificationInfo[@"Error"].localizedDescription;
|
|
84
|
+
message[@"code"] = notificationInfo[@"Error"].description;
|
|
70
85
|
|
|
71
86
|
if (hasListeners)
|
|
72
|
-
[self sendEventWithName:@"ROOK_NOTIFICATION" body:
|
|
87
|
+
[self sendEventWithName:@"ROOK_NOTIFICATION" body: message];
|
|
73
88
|
}
|
|
74
89
|
}
|
|
75
90
|
|
|
@@ -81,6 +96,18 @@ DataSourceManagerObjc *sourceManager;
|
|
|
81
96
|
UserManager *userManager;
|
|
82
97
|
|
|
83
98
|
// MARK: - Configuration
|
|
99
|
+
/**
|
|
100
|
+
* Initializes the Rook SDK with the provided configuration.
|
|
101
|
+
*
|
|
102
|
+
* @param data A dictionary containing the configuration parameters:
|
|
103
|
+
* - clientUUID: The unique identifier for the client.
|
|
104
|
+
* - password: The client's secret key.
|
|
105
|
+
* - enableEventsBackgroundSync: A boolean indicating whether to enable background sync for events.
|
|
106
|
+
* - environment: The environment in which the SDK is running (production, sandbox, or development).
|
|
107
|
+
* - enableLogs: A boolean indicating whether console logs should be enabled.
|
|
108
|
+
* @param resolve A block called upon successful initialization.
|
|
109
|
+
* @param reject A block called if an error occurs during initialization.
|
|
110
|
+
*/
|
|
84
111
|
RCT_EXPORT_METHOD(initRook:(NSDictionary *) data
|
|
85
112
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
86
113
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -123,6 +150,12 @@ RCT_EXPORT_METHOD(initRook:(NSDictionary *) data
|
|
|
123
150
|
resolve(@(YES));
|
|
124
151
|
}
|
|
125
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Retrieves the user ID from the user manager.
|
|
155
|
+
*
|
|
156
|
+
* @param resolve A block called with the user ID if the operation is successful.
|
|
157
|
+
* @param reject A block called if an error occurs while retrieving the user ID.
|
|
158
|
+
*/
|
|
126
159
|
RCT_EXPORT_METHOD(getUserID: (RCTPromiseResolveBlock)resolve
|
|
127
160
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
128
161
|
|
|
@@ -139,6 +172,12 @@ RCT_EXPORT_METHOD(getUserID: (RCTPromiseResolveBlock)resolve
|
|
|
139
172
|
|
|
140
173
|
}
|
|
141
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Update the user ID from the user manager.
|
|
177
|
+
*
|
|
178
|
+
* @param resolve A block called with the user ID if the operation is successful.
|
|
179
|
+
* @param reject A block called if an error occurs while retrieving the user ID.
|
|
180
|
+
*/
|
|
142
181
|
RCT_EXPORT_METHOD(updateUserID: (NSString *) userID
|
|
143
182
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
144
183
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -154,6 +193,12 @@ RCT_EXPORT_METHOD(updateUserID: (NSString *) userID
|
|
|
154
193
|
|
|
155
194
|
}
|
|
156
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Clear the user ID from the user manager.
|
|
198
|
+
*
|
|
199
|
+
* @param resolve A block called with the user ID if the operation is successful.
|
|
200
|
+
* @param reject A block called if an error occurs while retrieving the user ID.
|
|
201
|
+
*/
|
|
157
202
|
RCT_EXPORT_METHOD(clearUserID: (RCTPromiseResolveBlock)resolve
|
|
158
203
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
159
204
|
|
|
@@ -168,6 +213,12 @@ RCT_EXPORT_METHOD(clearUserID: (RCTPromiseResolveBlock)resolve
|
|
|
168
213
|
|
|
169
214
|
}
|
|
170
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Remove the user ID from the ROOK services.
|
|
218
|
+
*
|
|
219
|
+
* @param resolve A block called with the user ID if the operation is successful.
|
|
220
|
+
* @param reject A block called if an error occurs while retrieving the user ID.
|
|
221
|
+
*/
|
|
171
222
|
RCT_EXPORT_METHOD(removeUserFromRook: (RCTPromiseResolveBlock)resolve
|
|
172
223
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
173
224
|
|
|
@@ -182,6 +233,12 @@ RCT_EXPORT_METHOD(removeUserFromRook: (RCTPromiseResolveBlock)resolve
|
|
|
182
233
|
|
|
183
234
|
}
|
|
184
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Checks if background sync is enabled.
|
|
238
|
+
*
|
|
239
|
+
* @param resolve A block called with a boolean value indicating whether sync is enabled.
|
|
240
|
+
* @param reject A block called if an error occurs (not applicable here).
|
|
241
|
+
*/
|
|
185
242
|
RCT_EXPORT_METHOD(isSyncEnable: (RCTPromiseResolveBlock)resolve
|
|
186
243
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
187
244
|
|
|
@@ -189,6 +246,12 @@ RCT_EXPORT_METHOD(isSyncEnable: (RCTPromiseResolveBlock)resolve
|
|
|
189
246
|
resolve(@(result));
|
|
190
247
|
}
|
|
191
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Enables background sync.
|
|
251
|
+
*
|
|
252
|
+
* @param resolve A block called upon successfully enabling sync.
|
|
253
|
+
* @param reject A block called if an error occurs (not applicable here).
|
|
254
|
+
*/
|
|
192
255
|
RCT_EXPORT_METHOD(enableSync: (RCTPromiseResolveBlock)resolve
|
|
193
256
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
194
257
|
|
|
@@ -197,6 +260,12 @@ RCT_EXPORT_METHOD(enableSync: (RCTPromiseResolveBlock)resolve
|
|
|
197
260
|
|
|
198
261
|
}
|
|
199
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Disable background sync.
|
|
265
|
+
*
|
|
266
|
+
* @param resolve A block called upon successfully enabling sync.
|
|
267
|
+
* @param reject A block called if an error occurs (not applicable here).
|
|
268
|
+
*/
|
|
200
269
|
RCT_EXPORT_METHOD(disableSync: (RCTPromiseResolveBlock)resolve
|
|
201
270
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
202
271
|
|
|
@@ -204,6 +273,12 @@ RCT_EXPORT_METHOD(disableSync: (RCTPromiseResolveBlock)resolve
|
|
|
204
273
|
resolve(@(YES));
|
|
205
274
|
}
|
|
206
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Synchronizes the user's time zone with the user manager.
|
|
278
|
+
*
|
|
279
|
+
* @param resolve A block called with a boolean value indicating whether the time zone sync was successful.
|
|
280
|
+
* @param reject A block called if an error occurs during the sync process.
|
|
281
|
+
*/
|
|
207
282
|
RCT_EXPORT_METHOD(syncUserTimeZone: (RCTPromiseResolveBlock)resolve
|
|
208
283
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
209
284
|
|
|
@@ -219,6 +294,12 @@ RCT_EXPORT_METHOD(syncUserTimeZone: (RCTPromiseResolveBlock)resolve
|
|
|
219
294
|
}
|
|
220
295
|
|
|
221
296
|
// MARK: - Permissions
|
|
297
|
+
/**
|
|
298
|
+
* Requests all available permissions from the permissions manager.
|
|
299
|
+
*
|
|
300
|
+
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
301
|
+
* @param reject A block called if an error occurs during the permission request process.
|
|
302
|
+
*/
|
|
222
303
|
RCT_EXPORT_METHOD(requestAllPermissions: (RCTPromiseResolveBlock)resolve
|
|
223
304
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
224
305
|
|
|
@@ -233,6 +314,12 @@ RCT_EXPORT_METHOD(requestAllPermissions: (RCTPromiseResolveBlock)resolve
|
|
|
233
314
|
|
|
234
315
|
}
|
|
235
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Requests sleep permissions from the permissions manager.
|
|
319
|
+
*
|
|
320
|
+
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
321
|
+
* @param reject A block called if an error occurs during the permission request process.
|
|
322
|
+
*/
|
|
236
323
|
RCT_EXPORT_METHOD(requestSleepPermissions: (RCTPromiseResolveBlock)resolve
|
|
237
324
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
238
325
|
|
|
@@ -247,6 +334,12 @@ RCT_EXPORT_METHOD(requestSleepPermissions: (RCTPromiseResolveBlock)resolve
|
|
|
247
334
|
|
|
248
335
|
}
|
|
249
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Requests user info permissions from the permissions manager.
|
|
339
|
+
*
|
|
340
|
+
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
341
|
+
* @param reject A block called if an error occurs during the permission request process.
|
|
342
|
+
*/
|
|
250
343
|
RCT_EXPORT_METHOD(requestUserInfoPermissions: (RCTPromiseResolveBlock)resolve
|
|
251
344
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
252
345
|
[permissionsManager requestUserInfoPermissionsObjcWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
@@ -260,6 +353,12 @@ RCT_EXPORT_METHOD(requestUserInfoPermissions: (RCTPromiseResolveBlock)resolve
|
|
|
260
353
|
|
|
261
354
|
}
|
|
262
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Requests physical permissions from the permissions manager.
|
|
358
|
+
*
|
|
359
|
+
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
360
|
+
* @param reject A block called if an error occurs during the permission request process.
|
|
361
|
+
*/
|
|
263
362
|
RCT_EXPORT_METHOD(requestPhysicalPermissions: (RCTPromiseResolveBlock)resolve
|
|
264
363
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
265
364
|
|
|
@@ -274,6 +373,12 @@ RCT_EXPORT_METHOD(requestPhysicalPermissions: (RCTPromiseResolveBlock)resolve
|
|
|
274
373
|
|
|
275
374
|
}
|
|
276
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Requests body permissions from the permissions manager.
|
|
378
|
+
*
|
|
379
|
+
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
380
|
+
* @param reject A block called if an error occurs during the permission request process.
|
|
381
|
+
*/
|
|
277
382
|
RCT_EXPORT_METHOD(requestBodyPermissions: (RCTPromiseResolveBlock)resolve
|
|
278
383
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
279
384
|
|
|
@@ -288,6 +393,12 @@ RCT_EXPORT_METHOD(requestBodyPermissions: (RCTPromiseResolveBlock)resolve
|
|
|
288
393
|
|
|
289
394
|
}
|
|
290
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Opens the Apple Health settings on the user's device.
|
|
398
|
+
*
|
|
399
|
+
* @param resolve A block called with a boolean value indicating whether the Apple Health settings were successfully opened.
|
|
400
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
401
|
+
*/
|
|
291
402
|
RCT_EXPORT_METHOD(openAppleHealthSettings: (RCTPromiseResolveBlock)resolve
|
|
292
403
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
293
404
|
|
|
@@ -308,7 +419,32 @@ RCT_EXPORT_METHOD(openAppleHealthSettings: (RCTPromiseResolveBlock)resolve
|
|
|
308
419
|
});
|
|
309
420
|
}
|
|
310
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Checks the permission status for a specific data type in Apple Health.
|
|
424
|
+
*
|
|
425
|
+
* @param type The type of data for which the permission status is being checked (e.g., steps, sleep).
|
|
426
|
+
* @param resolve A block called with the permission status (e.g., authorized, denied, not determined).
|
|
427
|
+
* @param reject A block called if an error occurs (not used here).
|
|
428
|
+
*/
|
|
429
|
+
RCT_EXPORT_METHOD(checkPermissionsStatus: (NSString * _Nullable) type
|
|
430
|
+
resolve: (RCTPromiseResolveBlock) resolve
|
|
431
|
+
reject: (RCTPromiseRejectBlock) reject) {
|
|
432
|
+
|
|
433
|
+
[permissionsManager checkPermissionStatusWithType:type completionHandler:^(NSString * _Nonnull status) {
|
|
434
|
+
|
|
435
|
+
resolve(status);
|
|
436
|
+
|
|
437
|
+
}];
|
|
438
|
+
|
|
439
|
+
}
|
|
440
|
+
|
|
311
441
|
// MARK: - Summaries
|
|
442
|
+
/**
|
|
443
|
+
* Syncs the yesterday summaries
|
|
444
|
+
*
|
|
445
|
+
* @param resolve A block called with a boolean value indicating whether the summaries were successfully sync.
|
|
446
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
447
|
+
*/
|
|
312
448
|
RCT_EXPORT_METHOD(syncYesterdaySummaries: (RCTPromiseResolveBlock)resolve
|
|
313
449
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
314
450
|
|
|
@@ -318,6 +454,12 @@ RCT_EXPORT_METHOD(syncYesterdaySummaries: (RCTPromiseResolveBlock)resolve
|
|
|
318
454
|
|
|
319
455
|
}
|
|
320
456
|
|
|
457
|
+
/**
|
|
458
|
+
* Sync sleep summary
|
|
459
|
+
*
|
|
460
|
+
* @param resolve A block called with a boolean value indicating whether the sleep summary were successfully sync.
|
|
461
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
462
|
+
*/
|
|
321
463
|
RCT_EXPORT_METHOD(syncSleepSummary: (NSString *) dateString
|
|
322
464
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
323
465
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -333,6 +475,12 @@ RCT_EXPORT_METHOD(syncSleepSummary: (NSString *) dateString
|
|
|
333
475
|
|
|
334
476
|
}
|
|
335
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Sync physical summary
|
|
480
|
+
*
|
|
481
|
+
* @param resolve A block called with a boolean value indicating whether the physical summary were successfully sync.
|
|
482
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
483
|
+
*/
|
|
336
484
|
RCT_EXPORT_METHOD(syncPhysicalSummary: (NSString *) dateString
|
|
337
485
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
338
486
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -348,6 +496,12 @@ RCT_EXPORT_METHOD(syncPhysicalSummary: (NSString *) dateString
|
|
|
348
496
|
|
|
349
497
|
}
|
|
350
498
|
|
|
499
|
+
/**
|
|
500
|
+
* Sync body summary
|
|
501
|
+
*
|
|
502
|
+
* @param resolve A block called with a boolean value indicating whether the body summary were successfully sync.
|
|
503
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
504
|
+
*/
|
|
351
505
|
RCT_EXPORT_METHOD(syncBodySummary: (NSString *) dateString
|
|
352
506
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
353
507
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -363,6 +517,12 @@ RCT_EXPORT_METHOD(syncBodySummary: (NSString *) dateString
|
|
|
363
517
|
|
|
364
518
|
}
|
|
365
519
|
|
|
520
|
+
/**
|
|
521
|
+
* Sync summaries that couldnt be sync due to an error
|
|
522
|
+
*
|
|
523
|
+
* @param resolve A block called with a boolean value indicating whether the summaries were successfully sync.
|
|
524
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
525
|
+
*/
|
|
366
526
|
RCT_EXPORT_METHOD(syncPendingSummaries: (RCTPromiseResolveBlock) resolve
|
|
367
527
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
368
528
|
|
|
@@ -378,6 +538,12 @@ RCT_EXPORT_METHOD(syncPendingSummaries: (RCTPromiseResolveBlock) resolve
|
|
|
378
538
|
}
|
|
379
539
|
|
|
380
540
|
// MARK: - Events
|
|
541
|
+
/**
|
|
542
|
+
* Syncs the events
|
|
543
|
+
*
|
|
544
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
545
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
546
|
+
*/
|
|
381
547
|
RCT_EXPORT_METHOD(syncYesterdayEvents: (RCTPromiseResolveBlock)resolve
|
|
382
548
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
383
549
|
|
|
@@ -387,6 +553,12 @@ RCT_EXPORT_METHOD(syncYesterdayEvents: (RCTPromiseResolveBlock)resolve
|
|
|
387
553
|
|
|
388
554
|
}
|
|
389
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Sync body heart rate event
|
|
558
|
+
*
|
|
559
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
560
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
561
|
+
*/
|
|
390
562
|
RCT_EXPORT_METHOD(syncBodyHeartRateEvent: (NSString *) dateString
|
|
391
563
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
392
564
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -401,6 +573,12 @@ RCT_EXPORT_METHOD(syncBodyHeartRateEvent: (NSString *) dateString
|
|
|
401
573
|
}];
|
|
402
574
|
}
|
|
403
575
|
|
|
576
|
+
/**
|
|
577
|
+
* Sync physical heart rate event
|
|
578
|
+
*
|
|
579
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
580
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
581
|
+
*/
|
|
404
582
|
RCT_EXPORT_METHOD(syncPhysicalHeartRateEvent: (NSString *) dateString
|
|
405
583
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
406
584
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -416,6 +594,12 @@ RCT_EXPORT_METHOD(syncPhysicalHeartRateEvent: (NSString *) dateString
|
|
|
416
594
|
}];
|
|
417
595
|
}
|
|
418
596
|
|
|
597
|
+
/**
|
|
598
|
+
* Sync body oxygenation event
|
|
599
|
+
*
|
|
600
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
601
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
602
|
+
*/
|
|
419
603
|
RCT_EXPORT_METHOD(syncBodyOxygenationEvent: (NSString *) dateString
|
|
420
604
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
421
605
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -430,6 +614,12 @@ RCT_EXPORT_METHOD(syncBodyOxygenationEvent: (NSString *) dateString
|
|
|
430
614
|
}];
|
|
431
615
|
}
|
|
432
616
|
|
|
617
|
+
/**
|
|
618
|
+
* Sync physical oxygenation event
|
|
619
|
+
*
|
|
620
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
621
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
622
|
+
*/
|
|
433
623
|
RCT_EXPORT_METHOD(syncPhysicalOxygenationEvent: (NSString *) dateString
|
|
434
624
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
435
625
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -444,6 +634,12 @@ RCT_EXPORT_METHOD(syncPhysicalOxygenationEvent: (NSString *) dateString
|
|
|
444
634
|
}];
|
|
445
635
|
}
|
|
446
636
|
|
|
637
|
+
/**
|
|
638
|
+
* Sync training event
|
|
639
|
+
*
|
|
640
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
641
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
642
|
+
*/
|
|
447
643
|
RCT_EXPORT_METHOD(syncTrainingEvent: (NSString *) dateString
|
|
448
644
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
449
645
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -458,6 +654,12 @@ RCT_EXPORT_METHOD(syncTrainingEvent: (NSString *) dateString
|
|
|
458
654
|
}];
|
|
459
655
|
}
|
|
460
656
|
|
|
657
|
+
/**
|
|
658
|
+
* Sync temperature event
|
|
659
|
+
*
|
|
660
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
661
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
662
|
+
*/
|
|
461
663
|
RCT_EXPORT_METHOD(syncTemperatureEvent: (NSString *) dateString
|
|
462
664
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
463
665
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -472,6 +674,12 @@ RCT_EXPORT_METHOD(syncTemperatureEvent: (NSString *) dateString
|
|
|
472
674
|
}];
|
|
473
675
|
}
|
|
474
676
|
|
|
677
|
+
/**
|
|
678
|
+
* Sync blood pressure event
|
|
679
|
+
*
|
|
680
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
681
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
682
|
+
*/
|
|
475
683
|
RCT_EXPORT_METHOD(syncPressureEvent: (NSString *) dateString
|
|
476
684
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
477
685
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -486,6 +694,12 @@ RCT_EXPORT_METHOD(syncPressureEvent: (NSString *) dateString
|
|
|
486
694
|
}];
|
|
487
695
|
}
|
|
488
696
|
|
|
697
|
+
/**
|
|
698
|
+
* Sync blood glucose event
|
|
699
|
+
*
|
|
700
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
701
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
702
|
+
*/
|
|
489
703
|
RCT_EXPORT_METHOD(syncGlucoseEvent: (NSString *) dateString
|
|
490
704
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
491
705
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -500,6 +714,12 @@ RCT_EXPORT_METHOD(syncGlucoseEvent: (NSString *) dateString
|
|
|
500
714
|
}];
|
|
501
715
|
}
|
|
502
716
|
|
|
717
|
+
/**
|
|
718
|
+
* Sync body metrics event
|
|
719
|
+
*
|
|
720
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
721
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
722
|
+
*/
|
|
503
723
|
RCT_EXPORT_METHOD(syncBodyMetricsEvent: (NSString *) dateString
|
|
504
724
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
505
725
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -515,7 +735,13 @@ RCT_EXPORT_METHOD(syncBodyMetricsEvent: (NSString *) dateString
|
|
|
515
735
|
}
|
|
516
736
|
|
|
517
737
|
// MARK: - Background
|
|
518
|
-
|
|
738
|
+
/**
|
|
739
|
+
* Enable the background sync, this will automatically upload events and summaries
|
|
740
|
+
* at the moment the user enables this feature.
|
|
741
|
+
*
|
|
742
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
743
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
744
|
+
*/
|
|
519
745
|
RCT_EXPORT_METHOD(enableBackGroundUpdates: (RCTPromiseResolveBlock) resolve
|
|
520
746
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
521
747
|
|
|
@@ -524,26 +750,52 @@ RCT_EXPORT_METHOD(enableBackGroundUpdates: (RCTPromiseResolveBlock) resolve
|
|
|
524
750
|
resolve(@(YES));
|
|
525
751
|
}
|
|
526
752
|
|
|
753
|
+
/**
|
|
754
|
+
* Disable the background sync
|
|
755
|
+
*
|
|
756
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
757
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
758
|
+
*/
|
|
527
759
|
RCT_EXPORT_METHOD(disableBackGroundUpdates: (RCTPromiseResolveBlock) resolve
|
|
528
760
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
529
761
|
|
|
530
762
|
[[RookBackGroundSync shared] disableBackGroundForSummaries];
|
|
531
763
|
|
|
532
764
|
[[RookBackGroundSync shared] disableBackGroundForEvents];
|
|
765
|
+
|
|
766
|
+
resolve(@(YES));
|
|
533
767
|
}
|
|
534
768
|
|
|
769
|
+
/**
|
|
770
|
+
* Enable background sync for summaries only
|
|
771
|
+
*
|
|
772
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
773
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
774
|
+
*/
|
|
535
775
|
RCT_EXPORT_METHOD(enableBackGroundEventUpdates: (RCTPromiseResolveBlock) resolve
|
|
536
776
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
537
777
|
[[RookBackGroundSync shared] enableBackGroundForEvents];
|
|
538
778
|
resolve(@(YES));
|
|
539
779
|
}
|
|
540
780
|
|
|
781
|
+
/**
|
|
782
|
+
* Disable the backGround sync just for events
|
|
783
|
+
*
|
|
784
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
785
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
786
|
+
*/
|
|
541
787
|
RCT_EXPORT_METHOD(disableBackGroundEventUpdates: (RCTPromiseResolveBlock) resolve
|
|
542
788
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
543
789
|
|
|
544
790
|
[[RookBackGroundSync shared] disableBackGroundForEvents];
|
|
545
791
|
}
|
|
546
792
|
|
|
793
|
+
/**
|
|
794
|
+
* Check if the background sync for summaries are enabled
|
|
795
|
+
*
|
|
796
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
797
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
798
|
+
*/
|
|
547
799
|
RCT_EXPORT_METHOD(isBackGroundForSummariesEnable: (RCTPromiseResolveBlock) resolve
|
|
548
800
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
549
801
|
|
|
@@ -551,6 +803,12 @@ RCT_EXPORT_METHOD(isBackGroundForSummariesEnable: (RCTPromiseResolveBlock) resol
|
|
|
551
803
|
resolve(@(result));
|
|
552
804
|
}
|
|
553
805
|
|
|
806
|
+
/**
|
|
807
|
+
* Check if the background sync for events are enabled
|
|
808
|
+
*
|
|
809
|
+
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
810
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
811
|
+
*/
|
|
554
812
|
RCT_EXPORT_METHOD(isBackGroundForEventsEnable: (RCTPromiseResolveBlock) resolve
|
|
555
813
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
556
814
|
|
|
@@ -559,6 +817,12 @@ RCT_EXPORT_METHOD(isBackGroundForEventsEnable: (RCTPromiseResolveBlock) resolve
|
|
|
559
817
|
}
|
|
560
818
|
|
|
561
819
|
// MARK: - Variables
|
|
820
|
+
/**
|
|
821
|
+
* Extract the steps from apple health
|
|
822
|
+
*
|
|
823
|
+
* @param resolve A block called with a string value indicating the steps.
|
|
824
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
825
|
+
*/
|
|
562
826
|
RCT_EXPORT_METHOD(getTodaySteps: (RCTPromiseResolveBlock) resolve
|
|
563
827
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
564
828
|
|
|
@@ -573,6 +837,12 @@ RCT_EXPORT_METHOD(getTodaySteps: (RCTPromiseResolveBlock) resolve
|
|
|
573
837
|
}
|
|
574
838
|
|
|
575
839
|
// MARK: - Connection Page
|
|
840
|
+
/**
|
|
841
|
+
* Check the authorizers and retrieve the sources available and configured
|
|
842
|
+
*
|
|
843
|
+
* @param resolve A block called with a boolean value indicating whether the result.
|
|
844
|
+
* @param reject A block called if an error occurs.
|
|
845
|
+
*/
|
|
576
846
|
RCT_EXPORT_METHOD(getAvailableDataSources: (NSDictionary *) options
|
|
577
847
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
578
848
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -595,6 +865,12 @@ RCT_EXPORT_METHOD(getAvailableDataSources: (NSDictionary *) options
|
|
|
595
865
|
}];
|
|
596
866
|
}
|
|
597
867
|
|
|
868
|
+
/**
|
|
869
|
+
* Check the authorizers and present a default view.
|
|
870
|
+
*
|
|
871
|
+
* @param resolve A block called with a boolean value indicating whether the result.
|
|
872
|
+
* @param reject A block called if an error occurs.
|
|
873
|
+
*/
|
|
598
874
|
RCT_EXPORT_METHOD(presentDataSourceView: (NSDictionary *) options
|
|
599
875
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
600
876
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -612,6 +888,12 @@ RCT_EXPORT_METHOD(presentDataSourceView: (NSDictionary *) options
|
|
|
612
888
|
});
|
|
613
889
|
}
|
|
614
890
|
|
|
891
|
+
/**
|
|
892
|
+
* Revoke the access to a API source
|
|
893
|
+
*
|
|
894
|
+
* @param resolve A block called with a boolean value indicating whether the result is.
|
|
895
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
896
|
+
*/
|
|
615
897
|
RCT_EXPORT_METHOD(revokeDataSource: (NSString *) source
|
|
616
898
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
617
899
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -629,6 +911,12 @@ RCT_EXPORT_METHOD(revokeDataSource: (NSString *) source
|
|
|
629
911
|
|
|
630
912
|
// MARK: - RN Broadcast
|
|
631
913
|
|
|
914
|
+
/**
|
|
915
|
+
* Internal method to send messages to broadcast channel
|
|
916
|
+
*
|
|
917
|
+
* @param resolve A block called with a boolean value indicating whether the result is.
|
|
918
|
+
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
919
|
+
*/
|
|
632
920
|
RCT_EXPORT_METHOD(sendMessageToBroadcast: (NSDictionary *) message
|
|
633
921
|
resolve: (RCTPromiseResolveBlock) resolve
|
|
634
922
|
reject: (RCTPromiseRejectBlock) reject) {
|
|
@@ -7,7 +7,19 @@ exports.useRookSyncGateContext = exports.RookSyncGateContext = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
// RookSyncGateContext.tsx
|
|
9
9
|
|
|
10
|
+
/* This line of code is creating a context using the `createContext` function provided by React. The
|
|
11
|
+
context being created is named `RookSyncGateContext` and it is defined to hold an object with two
|
|
12
|
+
properties: `state` of type `RookSyncGateState` and `dispatch` of type `Dispatch<Action>`. The
|
|
13
|
+
`Dispatch` type is a generic type that represents a function to dispatch actions. */
|
|
10
14
|
const RookSyncGateContext = exports.RookSyncGateContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The function `useRookSyncGateContext` ensures that it is used within the `RookSyncGateProvider`
|
|
18
|
+
* context.
|
|
19
|
+
* @returns The `useRookSyncGateContext` custom hook is returning the context obtained from the
|
|
20
|
+
* `RookSyncGateContext` using the `useContext` hook. If the context is not found, it throws an error
|
|
21
|
+
* indicating that `useRookSyncGateContext` should be used inside `RookSyncGateProvider`.
|
|
22
|
+
*/
|
|
11
23
|
const useRookSyncGateContext = () => {
|
|
12
24
|
const context = (0, _react.useContext)(RookSyncGateContext);
|
|
13
25
|
if (!context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","RookSyncGateContext","exports","createContext","undefined","useRookSyncGateContext","context","useContext","Error"],"sourceRoot":"../../../src","sources":["context/RookSyncGateContext.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AADA;;
|
|
1
|
+
{"version":3,"names":["_react","require","RookSyncGateContext","exports","createContext","undefined","useRookSyncGateContext","context","useContext","Error"],"sourceRoot":"../../../src","sources":["context/RookSyncGateContext.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AADA;;AAIA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,gBAAG,IAAAE,oBAAa,EAE9CC,SAAS,CAAC;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACN,mBAAmB,CAAC;EAC/C,IAAI,CAACK,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CACb,mEACF,CAAC;EACH;EACA,OAAOF,OAAO;AAChB,CAAC;AAACJ,OAAA,CAAAG,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -7,7 +7,9 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _RookSyncGateReducer = require("./RookSyncGateReducer");
|
|
9
9
|
var _RookSyncGateContext = require("./RookSyncGateContext");
|
|
10
|
-
var
|
|
10
|
+
var _credentials = require("../utils/credentials");
|
|
11
|
+
var _getRookModule = require("../utils/getRookModule");
|
|
12
|
+
var _packageInfo = require("../utils/packageInfo");
|
|
11
13
|
var _useRookAutoSync = require("../modules/hook/useRookAutoSync");
|
|
12
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -23,6 +25,11 @@ const initialState = {
|
|
|
23
25
|
userID: '',
|
|
24
26
|
permissions: 0
|
|
25
27
|
};
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* This code snippet is defining a React functional component called `RookSyncGateProvider`.
|
|
31
|
+
* this define the provider for the SDK
|
|
32
|
+
*/
|
|
26
33
|
const RookSyncGateProvider = ({
|
|
27
34
|
environment,
|
|
28
35
|
clientUUID,
|
|
@@ -57,11 +64,11 @@ const RookSyncGateProvider = ({
|
|
|
57
64
|
password
|
|
58
65
|
});
|
|
59
66
|
try {
|
|
60
|
-
const rookSyncModule = (0,
|
|
67
|
+
const rookSyncModule = (0, _getRookModule.getRookModule)();
|
|
61
68
|
await rookSyncModule.initRook({
|
|
62
|
-
environment:
|
|
63
|
-
clientUUID:
|
|
64
|
-
password:
|
|
69
|
+
environment: _packageInfo.packageInfo.debug ? 'development' : environment,
|
|
70
|
+
clientUUID: _packageInfo.packageInfo.debug ? _credentials.credentials.uuid : clientUUID,
|
|
71
|
+
password: _packageInfo.packageInfo.debug ? _credentials.credentials.pdw : password,
|
|
65
72
|
enableLogs,
|
|
66
73
|
enableEventsBackgroundSync,
|
|
67
74
|
enableBackground: enableBackgroundSync
|