瀏覽代碼

Reject promise by iOS openDocument when a file is not opened

Gennady Basov 6 年之前
父節點
當前提交
c5de6f806b
共有 1 個檔案被更改,包括 5 行新增2 行删除
  1. 5
    2
      ios/RNFetchBlob/RNFetchBlob.m

+ 5
- 2
ios/RNFetchBlob/RNFetchBlob.m 查看文件

@@ -588,9 +588,12 @@ RCT_EXPORT_METHOD(openDocument:(NSString*)uri scheme:(NSString *)scheme resolver
588 588
 
589 589
     if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
590 590
         dispatch_sync(dispatch_get_main_queue(), ^{
591
-            [documentController presentPreviewAnimated:YES];
591
+            if([documentController presentPreviewAnimated:YES]) {
592
+                resolve(@[[NSNull null]]);
593
+            } else {
594
+                reject(@"EINVAL", @"document is not supported", nil);
595
+            }
592 596
         });
593
-        resolve(@[[NSNull null]]);
594 597
     } else {
595 598
         reject(@"EINVAL", @"scheme is not supported", nil);
596 599
     }