Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ function previewDocument(path:string, scheme:string) {
* Preview a file using UIDocumentInteractionController
* @param {string]} path Path of the file to be open.
* @param {string} scheme URI scheme that needs to support, optional
* @param {string} name The name of the target file, optional
* @return {Promise}
*/
function openDocument(path:string, scheme:string) {
function openDocument(path:string, scheme:string, name: string) {
if(Platform.OS === 'ios')
return RNFetchBlob.openDocument('file://' + path, scheme)
return RNFetchBlob.openDocument('file://' + path, scheme, name)
else
return Promise.reject('RNFetchBlob.previewDocument only supports IOS.')
}
Expand Down
3 changes: 2 additions & 1 deletion ios/RNFetchBlob/RNFetchBlob.m
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,14 @@ - (NSDictionary *)constantsToExport

# pragma mark - open file with UIDocumentInteractionController and delegate

RCT_EXPORT_METHOD(openDocument:(NSString*)uri scheme:(NSString *)scheme resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(openDocument:(NSString*)uri scheme:(NSString *)scheme name:(NSString*)name resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL * url = [[NSURL alloc] initWithString:utf8uri];
// NSURL * url = [[NSURL alloc] initWithString:uri];
documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
documentController.delegate = self;
documentController.name = name;

if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
dispatch_sync(dispatch_get_main_queue(), ^{
Expand Down