@@ -314,7 +314,7 @@ - (NSDictionary *)constantsToExport
314
314
#pragma mark - fs.stat
315
315
RCT_EXPORT_METHOD (stat:(NSString *)target callback:(RCTResponseSenderBlock) callback)
316
316
{
317
-
317
+
318
318
[RNFetchBlobFS getPathFromUri: target completionHandler: ^(NSString *path, ALAssetRepresentation *asset) {
319
319
__block NSMutableArray * result;
320
320
if (path != nil )
@@ -323,14 +323,14 @@ - (NSDictionary *)constantsToExport
323
323
BOOL exist = nil ;
324
324
BOOL isDir = nil ;
325
325
NSError * error = nil ;
326
-
326
+
327
327
exist = [fm fileExistsAtPath: path isDirectory: &isDir];
328
328
if (exist == NO ) {
329
329
callback (@[[NSString stringWithFormat: @" failed to stat path `%@ ` for it is not exist or it is not exist" , path]]);
330
330
return ;
331
331
}
332
332
result = [RNFetchBlobFS stat: path error: &error];
333
-
333
+
334
334
if (error == nil )
335
335
callback (@[[NSNull null ], result]);
336
336
else
@@ -389,7 +389,7 @@ - (NSDictionary *)constantsToExport
389
389
#pragma mark - fs.cp
390
390
RCT_EXPORT_METHOD (cp:(NSString *)src toPath:(NSString *)dest callback:(RCTResponseSenderBlock) callback)
391
391
{
392
-
392
+
393
393
// path = [RNFetchBlobFS getPathOfAsset:path];
394
394
[RNFetchBlobFS getPathFromUri: src completionHandler: ^(NSString *path, ALAssetRepresentation *asset) {
395
395
NSError * error = nil ;
@@ -401,14 +401,14 @@ - (NSDictionary *)constantsToExport
401
401
else
402
402
{
403
403
BOOL result = [[NSFileManager defaultManager ] copyItemAtURL: [NSURL fileURLWithPath: path] toURL: [NSURL fileURLWithPath: dest] error: &error];
404
-
404
+
405
405
if (error == nil )
406
406
callback (@[[NSNull null ], @YES ]);
407
407
else
408
408
callback (@[[error localizedDescription ], @NO ]);
409
409
}
410
410
}];
411
-
411
+
412
412
}
413
413
414
414
@@ -470,7 +470,7 @@ - (NSDictionary *)constantsToExport
470
470
else
471
471
bufferSize = 4096 ;
472
472
}
473
-
473
+
474
474
dispatch_async (fsQueue, ^{
475
475
[RNFetchBlobFS readStream: path encoding: encoding bufferSize: bufferSize tick: tick streamId: streamId bridgeRef: _bridge];
476
476
});
@@ -496,7 +496,7 @@ - (NSDictionary *)constantsToExport
496
496
#pragma mark - net.enableProgressReport
497
497
RCT_EXPORT_METHOD (enableProgressReport:(NSString *)taskId interval:(nonnull NSNumber *)interval count:(nonnull NSNumber *)count)
498
498
{
499
-
499
+
500
500
RNFetchBlobProgress * cfg = [[RNFetchBlobProgress alloc ] initWithType: Download interval: interval count: count];
501
501
[RNFetchBlobNetwork enableProgressReport: taskId config: cfg];
502
502
}
@@ -523,9 +523,10 @@ - (NSDictionary *)constantsToExport
523
523
UIViewController *rootCtrl = [[[[UIApplication sharedApplication ] delegate ] window ] rootViewController ];
524
524
documentController.delegate = self;
525
525
if (scheme == nil || [[UIApplication sharedApplication ] canOpenURL: [NSURL URLWithString: scheme]]) {
526
- dispatch_sync (dispatch_get_main_queue (), ^{
527
- [documentController presentOptionsMenuFromRect: rootCtrl.view.bounds inView: rootCtrl.view animated: YES ];
528
- });
526
+ CGRect rect = CGRectMake (0.0 , 0.0 , 0.0 , 0.0 );
527
+ dispatch_sync (dispatch_get_main_queue (), ^{
528
+ [documentController presentOptionsMenuFromRect: rect inView: rootCtrl.view animated: YES ];
529
+ });
529
530
resolve (@[[NSNull null ]]);
530
531
} else {
531
532
reject (@" RNFetchBlob could not open document" , @" scheme is not supported" , nil );
@@ -541,7 +542,7 @@ - (NSDictionary *)constantsToExport
541
542
// NSURL * url = [[NSURL alloc] initWithString:uri];
542
543
documentController = [UIDocumentInteractionController interactionControllerWithURL: url];
543
544
documentController.delegate = self;
544
-
545
+
545
546
if (scheme == nil || [[UIApplication sharedApplication ] canOpenURL: [NSURL URLWithString: scheme]]) {
546
547
dispatch_sync (dispatch_get_main_queue (), ^{
547
548
[documentController presentPreviewAnimated: YES ];
@@ -564,7 +565,7 @@ - (NSDictionary *)constantsToExport
564
565
} else {
565
566
reject (@" RNFetchBlob could not open document" , [error description ], nil );
566
567
}
567
-
568
+
568
569
}
569
570
570
571
@@ -580,11 +581,24 @@ - (UIViewController *) documentInteractionControllerViewControllerForPreview: (U
580
581
}
581
582
582
583
# pragma mark - getCookies
584
+
583
585
RCT_EXPORT_METHOD (getCookies:(NSString *)url resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
584
586
{
585
587
resolve ([RNFetchBlobNetwork getCookies: url]);
586
588
}
587
589
590
+ # pragma mark - removeCookie
591
+
592
+ RCT_EXPORT_METHOD (removeCookies:(NSString *)domain resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
593
+ {
594
+ NSError * err = nil ;
595
+ [RNFetchBlobNetwork removeCookies: domain error: &err];
596
+ if (err)
597
+ reject (@" RNFetchBlob failed to remove cookie" , @" RNFetchBlob failed to remove cookie" , nil );
598
+ else
599
+ resolve (@[[NSNull null ]]);
600
+ }
601
+
588
602
# pragma mark - check expired network events
589
603
590
604
RCT_EXPORT_METHOD (emitExpiredEvent:(RCTResponseSenderBlock)callback)
@@ -593,4 +607,6 @@ - (UIViewController *) documentInteractionControllerViewControllerForPreview: (U
593
607
}
594
608
595
609
610
+
611
+
596
612
@end
0 commit comments