From f337dc5a2fde3bdf58e3b4efc73b28b2cf161e56 Mon Sep 17 00:00:00 2001 From: Mark Holland Date: Mon, 4 Jul 2022 17:41:28 +0200 Subject: [PATCH] Check on iOS if can preview before opening --- ios/RNFileViewerManager.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ios/RNFileViewerManager.m b/ios/RNFileViewerManager.m index 8149cac..bff6b37 100644 --- a/ios/RNFileViewerManager.m +++ b/ios/RNFileViewerManager.m @@ -118,9 +118,13 @@ - (void)previewControllerDidDismiss:(CustomQLViewController *)controller { controller.delegate = self; typeof(self) __weak weakSelf = self; - [[RNFileViewer topViewController] presentViewController:controller animated:YES completion:^{ - [weakSelf sendEventWithName:OPEN_EVENT body: @{@"id": invocationId}]; - }]; + if([QLPreviewController canPreviewItem:file]) { + [[RNFileViewer topViewController] presentViewController:controller animated:YES completion:^{ + [weakSelf sendEventWithName:OPEN_EVENT body: @{@"id": invocationId}]; + }]; + } else { + [weakSelf sendEventWithName:OPEN_EVENT body: @{@"id": invocationId, @"error": @"File not supported"}]; + } } @end