react-native-rook-sdk 1.0.1 → 1.1.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/build.gradle +3 -1
- package/android/src/main/java/com/rooksdk/modules/RookSyncModule.kt +15 -0
- package/ios/RookBackgroundModule.h +5 -0
- package/ios/RookBackgroundModule.mm +89 -0
- package/ios/RookConfigurationModule.h +5 -0
- package/ios/RookConfigurationModule.mm +163 -0
- package/ios/RookPermissionsModule.h +5 -0
- package/ios/RookPermissionsModule.mm +180 -0
- package/ios/RookSdk.h +0 -7
- package/ios/RookSdk.mm +0 -796
- package/ios/RookSourcesModule.h +5 -0
- package/ios/RookSourcesModule.mm +116 -0
- package/ios/RookSyncModule.h +5 -0
- package/ios/RookSyncModule.mm +363 -0
- package/lib/commonjs/context/index.js +1 -1
- package/lib/commonjs/context/index.js.map +1 -1
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js +1 -1
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
- package/lib/commonjs/hooks/useRookAppleHealth.js +2 -2
- package/lib/commonjs/hooks/useRookAppleHealth.js.map +1 -1
- package/lib/commonjs/hooks/useRookAppleHealthVariables.js +2 -2
- package/lib/commonjs/hooks/useRookAppleHealthVariables.js.map +1 -1
- package/lib/commonjs/hooks/useRookConfiguration.js +2 -2
- package/lib/commonjs/hooks/useRookConfiguration.js.map +1 -1
- package/lib/commonjs/hooks/useRookDataSources.js +21 -3
- package/lib/commonjs/hooks/useRookDataSources.js.map +1 -1
- package/lib/commonjs/hooks/useRookEvents.js +2 -2
- package/lib/commonjs/hooks/useRookEvents.js.map +1 -1
- package/lib/commonjs/hooks/useRookPermissions.js +2 -2
- package/lib/commonjs/hooks/useRookPermissions.js.map +1 -1
- package/lib/commonjs/hooks/useRookSummaries.js +2 -2
- package/lib/commonjs/hooks/useRookSummaries.js.map +1 -1
- package/lib/commonjs/modules/hook/useRookAutoSync.js +8 -5
- package/lib/commonjs/modules/hook/useRookAutoSync.js.map +1 -1
- package/lib/commonjs/types/AuthorizedSources.js +2 -0
- package/lib/commonjs/types/AuthorizedSources.js.map +1 -0
- package/lib/commonjs/utils/getNativeModule.js.map +1 -1
- package/lib/commonjs/utils/getRookModule.js.map +1 -1
- package/lib/commonjs/utils/isValidDate.js.map +1 -1
- package/lib/commonjs/utils/nativeModules.js +6 -1
- package/lib/commonjs/utils/nativeModules.js.map +1 -1
- package/lib/module/hooks/useRookAppleHealth.js +1 -1
- package/lib/module/hooks/useRookAppleHealth.js.map +1 -1
- package/lib/module/hooks/useRookAppleHealthVariables.js +1 -1
- package/lib/module/hooks/useRookAppleHealthVariables.js.map +1 -1
- package/lib/module/hooks/useRookConfiguration.js +1 -1
- package/lib/module/hooks/useRookConfiguration.js.map +1 -1
- package/lib/module/hooks/useRookDataSources.js +20 -2
- package/lib/module/hooks/useRookDataSources.js.map +1 -1
- package/lib/module/hooks/useRookEvents.js +1 -1
- package/lib/module/hooks/useRookEvents.js.map +1 -1
- package/lib/module/hooks/useRookPermissions.js +1 -1
- package/lib/module/hooks/useRookPermissions.js.map +1 -1
- package/lib/module/hooks/useRookSummaries.js +1 -1
- package/lib/module/hooks/useRookSummaries.js.map +1 -1
- package/lib/module/modules/hook/useRookAutoSync.js +7 -4
- package/lib/module/modules/hook/useRookAutoSync.js.map +1 -1
- package/lib/module/types/AuthorizedSources.js +2 -0
- package/lib/module/types/AuthorizedSources.js.map +1 -0
- package/lib/module/utils/getNativeModule.js.map +1 -1
- package/lib/module/utils/getRookModule.js.map +1 -1
- package/lib/module/utils/isRunningOnAndroid.js +2 -2
- package/lib/module/utils/isRunningOnAndroid.js.map +1 -1
- package/lib/module/utils/isValidDate.js.map +1 -1
- package/lib/module/utils/nativeModules.js +6 -1
- package/lib/module/utils/nativeModules.js.map +1 -1
- package/lib/typescript/src/hooks/useRookDataSources.d.ts +2 -0
- package/lib/typescript/src/hooks/useRookDataSources.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookPermissions.d.ts +1 -2
- package/lib/typescript/src/hooks/useRookPermissions.d.ts.map +1 -1
- package/lib/typescript/src/modules/hook/useRookAutoSync.d.ts.map +1 -1
- package/lib/typescript/src/types/AuthorizedSources.d.ts +13 -0
- package/lib/typescript/src/types/AuthorizedSources.d.ts.map +1 -0
- package/lib/typescript/src/types/PermissionsType.d.ts +1 -1
- package/lib/typescript/src/types/PermissionsType.d.ts.map +1 -1
- package/lib/typescript/src/utils/nativeModules.d.ts +5 -0
- package/lib/typescript/src/utils/nativeModules.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-rook-sdk.podspec +1 -1
package/ios/RookSdk.mm
CHANGED
|
@@ -11,20 +11,6 @@ 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.
|
|
18
|
-
NSDate *parseDateFromString(NSString * dateString) {
|
|
19
|
-
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
|
20
|
-
|
|
21
|
-
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
|
|
22
|
-
|
|
23
|
-
NSDate *date = [dateFormatter dateFromString:dateString];
|
|
24
|
-
|
|
25
|
-
return date;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
14
|
// A function that takes an NSException object as input and creates an
|
|
29
15
|
// NSError object based on the exception information. It creates a dictionary with localized
|
|
30
16
|
// description and failure reason keys using the exception's name and reason properties. Then, it
|
|
@@ -89,11 +75,6 @@ RCT_EXPORT_MODULE()
|
|
|
89
75
|
}
|
|
90
76
|
|
|
91
77
|
RookConnectConfigurationManagerObjc *shared;
|
|
92
|
-
RookConnectPermissionsManager *permissionsManager;
|
|
93
|
-
RookSummaryManager *summaryManager;
|
|
94
|
-
RookEventsManager *eventsManager;
|
|
95
|
-
DataSourceManagerObjc *sourceManager;
|
|
96
|
-
UserManager *userManager;
|
|
97
78
|
|
|
98
79
|
// MARK: - Configuration
|
|
99
80
|
/**
|
|
@@ -141,787 +122,10 @@ RCT_EXPORT_METHOD(initRook:(NSDictionary *) data
|
|
|
141
122
|
[shared setConsoleLogAvailable: enableLogs];
|
|
142
123
|
[shared initRook];
|
|
143
124
|
|
|
144
|
-
permissionsManager = [RookConnectPermissionsManager new];
|
|
145
|
-
summaryManager = [RookSummaryManager new];
|
|
146
|
-
eventsManager = [RookEventsManager new];
|
|
147
|
-
sourceManager = [DataSourceManagerObjc new];
|
|
148
|
-
userManager = [UserManager new];
|
|
149
|
-
|
|
150
125
|
resolve(@(YES));
|
|
151
126
|
}
|
|
152
127
|
|
|
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
|
-
*/
|
|
159
|
-
RCT_EXPORT_METHOD(getUserID: (RCTPromiseResolveBlock)resolve
|
|
160
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
161
|
-
|
|
162
|
-
[userManager readUserIdWithCompletion:^(NSString * _Nullable userID, NSError * _Nullable error) {
|
|
163
|
-
|
|
164
|
-
if(error != nil) {
|
|
165
|
-
reject(error.description, error.localizedDescription, error);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
resolve(userID);
|
|
170
|
-
|
|
171
|
-
}];
|
|
172
|
-
|
|
173
|
-
}
|
|
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
|
-
*/
|
|
181
|
-
RCT_EXPORT_METHOD(updateUserID: (NSString *) userID
|
|
182
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
183
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
184
|
-
|
|
185
|
-
[userManager updateUserId:userID completion:^(BOOL success, NSError * _Nullable error) {
|
|
186
|
-
if(error != nil) {
|
|
187
|
-
reject(error.description, error.localizedDescription, error);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
resolve(@(success));
|
|
192
|
-
}];
|
|
193
|
-
|
|
194
|
-
}
|
|
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
|
-
*/
|
|
202
|
-
RCT_EXPORT_METHOD(clearUserID: (RCTPromiseResolveBlock)resolve
|
|
203
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
204
|
-
|
|
205
|
-
[userManager clearUserWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
206
|
-
if(error != nil) {
|
|
207
|
-
reject(error.description, error.localizedDescription, error);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
resolve(@(success));
|
|
212
|
-
}];
|
|
213
|
-
|
|
214
|
-
}
|
|
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
|
-
*/
|
|
222
|
-
RCT_EXPORT_METHOD(removeUserFromRook: (RCTPromiseResolveBlock)resolve
|
|
223
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
224
|
-
|
|
225
|
-
[userManager removeUserFromRookWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
226
|
-
if(error != nil) {
|
|
227
|
-
reject(error.description, error.localizedDescription, error);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
resolve(@(success));
|
|
232
|
-
}];
|
|
233
|
-
|
|
234
|
-
}
|
|
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
|
-
*/
|
|
242
|
-
RCT_EXPORT_METHOD(isSyncEnable: (RCTPromiseResolveBlock)resolve
|
|
243
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
244
|
-
|
|
245
|
-
bool result = [shared isSyncEnable];
|
|
246
|
-
resolve(@(result));
|
|
247
|
-
}
|
|
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
|
-
*/
|
|
255
|
-
RCT_EXPORT_METHOD(enableSync: (RCTPromiseResolveBlock)resolve
|
|
256
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
257
|
-
|
|
258
|
-
[shared enableSync];
|
|
259
|
-
resolve(@(YES));
|
|
260
|
-
|
|
261
|
-
}
|
|
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
|
-
*/
|
|
269
|
-
RCT_EXPORT_METHOD(disableSync: (RCTPromiseResolveBlock)resolve
|
|
270
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
271
|
-
|
|
272
|
-
[shared disableSync];
|
|
273
|
-
resolve(@(YES));
|
|
274
|
-
}
|
|
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
|
-
*/
|
|
282
|
-
RCT_EXPORT_METHOD(syncUserTimeZone: (RCTPromiseResolveBlock)resolve
|
|
283
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
284
|
-
|
|
285
|
-
[userManager syncUserTimeZoneWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
286
|
-
if(error != nil) {
|
|
287
|
-
reject(error.description, error.localizedDescription, error);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
resolve(@(success));
|
|
292
|
-
}];
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// MARK: - Permissions
|
|
297
|
-
RCT_EXPORT_METHOD(requestPermissions: (NSArray<NSString *> * _Nullable)permissions
|
|
298
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
299
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
300
|
-
|
|
301
|
-
[permissionsManager requestPermissions:permissions completion:^(BOOL success, NSError * _Nullable error) {
|
|
302
|
-
if(error != nil) {
|
|
303
|
-
reject(error.description, error.localizedDescription, error);
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
resolve(@(success));
|
|
308
|
-
}];
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Requests all available permissions from the permissions manager.
|
|
313
|
-
*
|
|
314
|
-
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
315
|
-
* @param reject A block called if an error occurs during the permission request process.
|
|
316
|
-
*/
|
|
317
|
-
RCT_EXPORT_METHOD(requestAllPermissions: (RCTPromiseResolveBlock)resolve
|
|
318
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
319
|
-
|
|
320
|
-
[permissionsManager requestAllPermissionsObjcWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
321
|
-
if(error != nil) {
|
|
322
|
-
reject(error.description, error.localizedDescription, error);
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
resolve(@(success));
|
|
327
|
-
}];
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Requests sleep permissions from the permissions manager.
|
|
333
|
-
*
|
|
334
|
-
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
335
|
-
* @param reject A block called if an error occurs during the permission request process.
|
|
336
|
-
*/
|
|
337
|
-
RCT_EXPORT_METHOD(requestSleepPermissions: (RCTPromiseResolveBlock)resolve
|
|
338
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
339
|
-
|
|
340
|
-
[permissionsManager requestSleepPermissionsObjcWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
341
|
-
if(error != nil) {
|
|
342
|
-
reject(error.description, error.localizedDescription, error);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
resolve(@(success));
|
|
347
|
-
}];
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Requests user info permissions from the permissions manager.
|
|
353
|
-
*
|
|
354
|
-
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
355
|
-
* @param reject A block called if an error occurs during the permission request process.
|
|
356
|
-
*/
|
|
357
|
-
RCT_EXPORT_METHOD(requestUserInfoPermissions: (RCTPromiseResolveBlock)resolve
|
|
358
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
359
|
-
[permissionsManager requestUserInfoPermissionsObjcWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
360
|
-
if(error != nil) {
|
|
361
|
-
reject(error.description, error.localizedDescription, error);
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
resolve(@(success));
|
|
366
|
-
}];
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Requests physical permissions from the permissions manager.
|
|
372
|
-
*
|
|
373
|
-
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
374
|
-
* @param reject A block called if an error occurs during the permission request process.
|
|
375
|
-
*/
|
|
376
|
-
RCT_EXPORT_METHOD(requestPhysicalPermissions: (RCTPromiseResolveBlock)resolve
|
|
377
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
378
|
-
|
|
379
|
-
[permissionsManager requestPhysicalPermissionsObjcWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
380
|
-
if(error != nil) {
|
|
381
|
-
reject(error.description, error.localizedDescription, error);
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
resolve(@(success));
|
|
386
|
-
}];
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Requests body permissions from the permissions manager.
|
|
392
|
-
*
|
|
393
|
-
* @param resolve A block called with a boolean value indicating whether all permissions were successfully requested.
|
|
394
|
-
* @param reject A block called if an error occurs during the permission request process.
|
|
395
|
-
*/
|
|
396
|
-
RCT_EXPORT_METHOD(requestBodyPermissions: (RCTPromiseResolveBlock)resolve
|
|
397
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
398
|
-
|
|
399
|
-
[permissionsManager requestBodyPermissionsObjcWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
400
|
-
if(error != nil) {
|
|
401
|
-
reject(error.description, error.localizedDescription, error);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
resolve(@(success));
|
|
406
|
-
}];
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Opens the Apple Health settings on the user's device.
|
|
412
|
-
*
|
|
413
|
-
* @param resolve A block called with a boolean value indicating whether the Apple Health settings were successfully opened.
|
|
414
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
415
|
-
*/
|
|
416
|
-
RCT_EXPORT_METHOD(openAppleHealthSettings: (RCTPromiseResolveBlock)resolve
|
|
417
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
418
|
-
|
|
419
|
-
NSURL *urlSettings = [NSURL URLWithString:@"x-apple-health://"];
|
|
420
|
-
|
|
421
|
-
if (!urlSettings) {
|
|
422
|
-
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"Apple Health is not installed on iOS."};
|
|
423
|
-
NSError *error = [NSError errorWithDomain:@"io.ROOK.SDK" code:1001 userInfo:userInfo];
|
|
424
|
-
reject(error.description, error.localizedDescription, error);
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
430
|
-
[[UIApplication sharedApplication] openURL:urlSettings options:@{} completionHandler:^(BOOL success) {
|
|
431
|
-
resolve(@(success));
|
|
432
|
-
}];
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Checks the permission status for a specific data type in Apple Health.
|
|
438
|
-
*
|
|
439
|
-
* @param type The type of data for which the permission status is being checked (e.g., steps, sleep).
|
|
440
|
-
* @param resolve A block called with the permission status (e.g., authorized, denied, not determined).
|
|
441
|
-
* @param reject A block called if an error occurs (not used here).
|
|
442
|
-
*/
|
|
443
|
-
RCT_EXPORT_METHOD(checkPermissionsStatus: (NSString * _Nullable) type
|
|
444
|
-
resolve: (RCTPromiseResolveBlock) resolve
|
|
445
|
-
reject: (RCTPromiseRejectBlock) reject) {
|
|
446
|
-
|
|
447
|
-
[permissionsManager checkPermissionStatusWithType:type completionHandler:^(NSString * _Nonnull status) {
|
|
448
|
-
|
|
449
|
-
resolve(status);
|
|
450
|
-
|
|
451
|
-
}];
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// MARK: - Summaries
|
|
456
|
-
/**
|
|
457
|
-
* Syncs the yesterday summaries
|
|
458
|
-
*
|
|
459
|
-
* @param resolve A block called with a boolean value indicating whether the summaries were successfully sync.
|
|
460
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
461
|
-
*/
|
|
462
|
-
RCT_EXPORT_METHOD(syncYesterdaySummaries: (RCTPromiseResolveBlock)resolve
|
|
463
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
464
|
-
|
|
465
|
-
[summaryManager syncSummariesWithCompletion:^{
|
|
466
|
-
resolve(@(TRUE));
|
|
467
|
-
}];
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Sync sleep summary
|
|
473
|
-
*
|
|
474
|
-
* @param resolve A block called with a boolean value indicating whether the sleep summary were successfully sync.
|
|
475
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
476
|
-
*/
|
|
477
|
-
RCT_EXPORT_METHOD(syncSleepSummary: (NSString *) dateString
|
|
478
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
479
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
480
|
-
|
|
481
|
-
[summaryManager syncSleepSummaryObjcWithForm:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
482
|
-
if(error != nil) {
|
|
483
|
-
reject(error.description, error.localizedDescription, error);
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
resolve(@(success));
|
|
488
|
-
}];
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Sync physical summary
|
|
494
|
-
*
|
|
495
|
-
* @param resolve A block called with a boolean value indicating whether the physical summary were successfully sync.
|
|
496
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
497
|
-
*/
|
|
498
|
-
RCT_EXPORT_METHOD(syncPhysicalSummary: (NSString *) dateString
|
|
499
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
500
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
501
|
-
|
|
502
|
-
[summaryManager syncPhysicalSummaryObjcWithForm:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
503
|
-
if(error != nil) {
|
|
504
|
-
reject(error.description, error.localizedDescription, error);
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
resolve(@(success));
|
|
509
|
-
}];
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* Sync body summary
|
|
515
|
-
*
|
|
516
|
-
* @param resolve A block called with a boolean value indicating whether the body summary were successfully sync.
|
|
517
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
518
|
-
*/
|
|
519
|
-
RCT_EXPORT_METHOD(syncBodySummary: (NSString *) dateString
|
|
520
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
521
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
522
|
-
|
|
523
|
-
[summaryManager syncBodySummaryObjcFrom:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
524
|
-
if(error != nil) {
|
|
525
|
-
reject(error.description, error.localizedDescription, error);
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
resolve(@(success));
|
|
530
|
-
}];
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* Sync summaries that couldnt be sync due to an error
|
|
536
|
-
*
|
|
537
|
-
* @param resolve A block called with a boolean value indicating whether the summaries were successfully sync.
|
|
538
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
539
|
-
*/
|
|
540
|
-
RCT_EXPORT_METHOD(syncPendingSummaries: (RCTPromiseResolveBlock) resolve
|
|
541
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
542
|
-
|
|
543
|
-
[summaryManager syncPendingSummariesObjcWithCompletion:^(BOOL success, NSError * _Nullable error) {
|
|
544
|
-
if(error != nil) {
|
|
545
|
-
reject(error.description, error.localizedDescription, error);
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
resolve(@(success));
|
|
550
|
-
}];
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// MARK: - Events
|
|
555
|
-
/**
|
|
556
|
-
* Syncs the events
|
|
557
|
-
*
|
|
558
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
559
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
560
|
-
*/
|
|
561
|
-
RCT_EXPORT_METHOD(syncYesterdayEvents: (RCTPromiseResolveBlock)resolve
|
|
562
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
563
|
-
|
|
564
|
-
[eventsManager syncEventsWithCompletion:^{
|
|
565
|
-
resolve(@(TRUE));
|
|
566
|
-
}];
|
|
567
|
-
|
|
568
|
-
}
|
|
569
128
|
|
|
570
|
-
/**
|
|
571
|
-
* Sync body heart rate event
|
|
572
|
-
*
|
|
573
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
574
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
575
|
-
*/
|
|
576
|
-
RCT_EXPORT_METHOD(syncBodyHeartRateEvent: (NSString *) dateString
|
|
577
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
578
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
579
|
-
|
|
580
|
-
[eventsManager syncBodyHeartRateEventObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
581
|
-
if(error != nil) {
|
|
582
|
-
reject(error.description, error.localizedDescription, error);
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
resolve(@(success));
|
|
587
|
-
}];
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* Sync physical heart rate event
|
|
592
|
-
*
|
|
593
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
594
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
595
|
-
*/
|
|
596
|
-
RCT_EXPORT_METHOD(syncPhysicalHeartRateEvent: (NSString *) dateString
|
|
597
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
598
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
599
|
-
|
|
600
|
-
[eventsManager
|
|
601
|
-
syncPhysicalHeartRateEventObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
602
|
-
if(error != nil) {
|
|
603
|
-
reject(error.description, error.localizedDescription, error);
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
resolve(@(success));
|
|
608
|
-
}];
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Sync body oxygenation event
|
|
613
|
-
*
|
|
614
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
615
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
616
|
-
*/
|
|
617
|
-
RCT_EXPORT_METHOD(syncBodyOxygenationEvent: (NSString *) dateString
|
|
618
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
619
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
620
|
-
|
|
621
|
-
[eventsManager syncBodyOxygenationEventObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
622
|
-
if(error != nil) {
|
|
623
|
-
reject(error.description, error.localizedDescription, error);
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
resolve(@(success));
|
|
628
|
-
}];
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* Sync physical oxygenation event
|
|
633
|
-
*
|
|
634
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
635
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
636
|
-
*/
|
|
637
|
-
RCT_EXPORT_METHOD(syncPhysicalOxygenationEvent: (NSString *) dateString
|
|
638
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
639
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
640
|
-
|
|
641
|
-
[eventsManager syncPhysicalOxygenationEventObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
642
|
-
if(error != nil) {
|
|
643
|
-
reject(error.description, error.localizedDescription, error);
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
resolve(@(success));
|
|
648
|
-
}];
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Sync training event
|
|
653
|
-
*
|
|
654
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
655
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
656
|
-
*/
|
|
657
|
-
RCT_EXPORT_METHOD(syncTrainingEvent: (NSString *) dateString
|
|
658
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
659
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
660
|
-
|
|
661
|
-
[eventsManager syncTrainingEventObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
662
|
-
if(error != nil) {
|
|
663
|
-
reject(error.description, error.localizedDescription, error);
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
resolve(@(success));
|
|
668
|
-
}];
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Sync temperature event
|
|
673
|
-
*
|
|
674
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
675
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
676
|
-
*/
|
|
677
|
-
RCT_EXPORT_METHOD(syncTemperatureEvent: (NSString *) dateString
|
|
678
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
679
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
680
|
-
|
|
681
|
-
[eventsManager syncTemperatureEventsObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
682
|
-
if(error != nil) {
|
|
683
|
-
reject(error.description, error.localizedDescription, error);
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
resolve(@(success));
|
|
688
|
-
}];
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* Sync blood pressure event
|
|
693
|
-
*
|
|
694
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
695
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
696
|
-
*/
|
|
697
|
-
RCT_EXPORT_METHOD(syncPressureEvent: (NSString *) dateString
|
|
698
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
699
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
700
|
-
|
|
701
|
-
[eventsManager syncPressureEventsObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
702
|
-
if(error != nil) {
|
|
703
|
-
reject(error.description, error.localizedDescription, error);
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
resolve(@(success));
|
|
708
|
-
}];
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Sync blood glucose event
|
|
713
|
-
*
|
|
714
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
715
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
716
|
-
*/
|
|
717
|
-
RCT_EXPORT_METHOD(syncGlucoseEvent: (NSString *) dateString
|
|
718
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
719
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
720
|
-
|
|
721
|
-
[eventsManager syncGlucoseEventsObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
722
|
-
if(error != nil) {
|
|
723
|
-
reject(error.description, error.localizedDescription, error);
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
resolve(@(success));
|
|
728
|
-
}];
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* Sync body metrics event
|
|
733
|
-
*
|
|
734
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
735
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
736
|
-
*/
|
|
737
|
-
RCT_EXPORT_METHOD(syncBodyMetricsEvent: (NSString *) dateString
|
|
738
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
739
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
740
|
-
|
|
741
|
-
[eventsManager syncBodyMetricsEventsObjcWithDate:parseDateFromString(dateString) completion:^(BOOL success, NSError * _Nullable error) {
|
|
742
|
-
if(error != nil) {
|
|
743
|
-
reject(error.description, error.localizedDescription, error);
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
resolve(@(success));
|
|
748
|
-
}];
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// MARK: - Background
|
|
752
|
-
/**
|
|
753
|
-
* Enable the background sync, this will automatically upload events and summaries
|
|
754
|
-
* at the moment the user enables this feature.
|
|
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
|
-
*/
|
|
759
|
-
RCT_EXPORT_METHOD(enableBackGroundUpdates: (RCTPromiseResolveBlock) resolve
|
|
760
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
761
|
-
|
|
762
|
-
[[RookBackGroundSync shared] enableBackGroundForSummaries];
|
|
763
|
-
[[RookBackGroundSync shared] enableBackGroundForEvents];
|
|
764
|
-
resolve(@(YES));
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* Disable the background sync
|
|
769
|
-
*
|
|
770
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
771
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
772
|
-
*/
|
|
773
|
-
RCT_EXPORT_METHOD(disableBackGroundUpdates: (RCTPromiseResolveBlock) resolve
|
|
774
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
775
|
-
|
|
776
|
-
[[RookBackGroundSync shared] disableBackGroundForSummaries];
|
|
777
|
-
|
|
778
|
-
[[RookBackGroundSync shared] disableBackGroundForEvents];
|
|
779
|
-
|
|
780
|
-
resolve(@(YES));
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
/**
|
|
784
|
-
* Enable background sync for summaries only
|
|
785
|
-
*
|
|
786
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
787
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
788
|
-
*/
|
|
789
|
-
RCT_EXPORT_METHOD(enableBackGroundEventUpdates: (RCTPromiseResolveBlock) resolve
|
|
790
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
791
|
-
[[RookBackGroundSync shared] enableBackGroundForEvents];
|
|
792
|
-
resolve(@(YES));
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* Disable the backGround sync just for events
|
|
797
|
-
*
|
|
798
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
799
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
800
|
-
*/
|
|
801
|
-
RCT_EXPORT_METHOD(disableBackGroundEventUpdates: (RCTPromiseResolveBlock) resolve
|
|
802
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
803
|
-
|
|
804
|
-
[[RookBackGroundSync shared] disableBackGroundForEvents];
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* Check if the background sync for summaries are enabled
|
|
809
|
-
*
|
|
810
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
811
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
812
|
-
*/
|
|
813
|
-
RCT_EXPORT_METHOD(isBackGroundForSummariesEnable: (RCTPromiseResolveBlock) resolve
|
|
814
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
815
|
-
|
|
816
|
-
bool result = [[RookBackGroundSync shared] isBackGroundForSummariesEnable];
|
|
817
|
-
resolve(@(result));
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* Check if the background sync for events are enabled
|
|
822
|
-
*
|
|
823
|
-
* @param resolve A block called with a boolean value indicating whether the events were successfully sync.
|
|
824
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
825
|
-
*/
|
|
826
|
-
RCT_EXPORT_METHOD(isBackGroundForEventsEnable: (RCTPromiseResolveBlock) resolve
|
|
827
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
828
|
-
|
|
829
|
-
bool result = [[RookBackGroundSync shared] isBackGroundForEventsEnable];
|
|
830
|
-
resolve(@(result));
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
// MARK: - Variables
|
|
834
|
-
/**
|
|
835
|
-
* Extract the steps from apple health
|
|
836
|
-
*
|
|
837
|
-
* @param resolve A block called with a string value indicating the steps.
|
|
838
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
839
|
-
*/
|
|
840
|
-
RCT_EXPORT_METHOD(getTodaySteps: (RCTPromiseResolveBlock) resolve
|
|
841
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
842
|
-
|
|
843
|
-
[eventsManager getTodayStepCountWithCompletion:^(NSInteger steps, NSError * _Nullable error) {
|
|
844
|
-
if(error != nil) {
|
|
845
|
-
reject(error.description, error.localizedDescription, error);
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
resolve(@(steps));
|
|
849
|
-
}];
|
|
850
|
-
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
// MARK: - Connection Page
|
|
854
|
-
/**
|
|
855
|
-
* Check the authorizers and retrieve the sources available and configured
|
|
856
|
-
*
|
|
857
|
-
* @param resolve A block called with a boolean value indicating whether the result.
|
|
858
|
-
* @param reject A block called if an error occurs.
|
|
859
|
-
*/
|
|
860
|
-
RCT_EXPORT_METHOD(getAvailableDataSources: (NSDictionary *) options
|
|
861
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
862
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
863
|
-
|
|
864
|
-
NSString *redirectURL = [RCTConvert NSString:options[@"redirectURL"]];
|
|
865
|
-
|
|
866
|
-
[sourceManager getAvailableDataSourcesWithRedirectURL:redirectURL
|
|
867
|
-
completion:^(NSArray<NSDictionary<NSString *,id> *> * _Nullable sources, NSError * _Nullable error) {
|
|
868
|
-
if (error) {
|
|
869
|
-
reject(error.description, error.localizedDescription, error);
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
if (sources) {
|
|
874
|
-
resolve(sources);
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
resolve([NSDictionary dictionary]);
|
|
879
|
-
}];
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
/**
|
|
883
|
-
* Check the authorizers and present a default view.
|
|
884
|
-
*
|
|
885
|
-
* @param resolve A block called with a boolean value indicating whether the result.
|
|
886
|
-
* @param reject A block called if an error occurs.
|
|
887
|
-
*/
|
|
888
|
-
RCT_EXPORT_METHOD(presentDataSourceView: (NSDictionary *) options
|
|
889
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
890
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
891
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
892
|
-
NSString *redirectURL = [RCTConvert NSString:options[@"redirectURL"]];
|
|
893
|
-
|
|
894
|
-
[sourceManager presentDataSourceViewWithRedirectURL:redirectURL completion:^(BOOL succeed, NSError * _Nullable error) {
|
|
895
|
-
if (error) {
|
|
896
|
-
reject(error.description, error.localizedDescription, error);
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
resolve(@(succeed));
|
|
901
|
-
}];
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* Revoke the access to a API source
|
|
907
|
-
*
|
|
908
|
-
* @param resolve A block called with a boolean value indicating whether the result is.
|
|
909
|
-
* @param reject A block called if an error occurs, such as Apple Health not being installed.
|
|
910
|
-
*/
|
|
911
|
-
RCT_EXPORT_METHOD(revokeDataSource: (NSString *) source
|
|
912
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
913
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
914
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
915
|
-
[userManager revokeDataSourceWithDataSource:source completion:^(BOOL succeed, NSError * _Nullable error) {
|
|
916
|
-
if (error) {
|
|
917
|
-
reject(error.description, error.localizedDescription, error);
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
resolve(@(succeed));
|
|
922
|
-
}];
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
129
|
|
|
926
130
|
// MARK: - RN Broadcast
|
|
927
131
|
|