Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit fffae8d

Browse files
tmdude9586wkh237
authored andcommitted
added the ability to specify the name for the uidocumentinteractioncontroller for ios (#485)
1 parent c9a2d48 commit fffae8d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ios.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ function previewDocument(path:string, scheme:string) {
2828
* Preview a file using UIDocumentInteractionController
2929
* @param {string]} path Path of the file to be open.
3030
* @param {string} scheme URI scheme that needs to support, optional
31+
* @param {string} name The name of the target file, optional
3132
* @return {Promise}
3233
*/
33-
function openDocument(path:string, scheme:string) {
34+
function openDocument(path:string, scheme:string, name: string) {
3435
if(Platform.OS === 'ios')
35-
return RNFetchBlob.openDocument('file://' + path, scheme)
36+
return RNFetchBlob.openDocument('file://' + path, scheme, name)
3637
else
3738
return Promise.reject('RNFetchBlob.previewDocument only supports IOS.')
3839
}

ios/RNFetchBlob/RNFetchBlob.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,14 @@ - (NSDictionary *)constantsToExport
536536

537537
# pragma mark - open file with UIDocumentInteractionController and delegate
538538

539-
RCT_EXPORT_METHOD(openDocument:(NSString*)uri scheme:(NSString *)scheme resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
539+
RCT_EXPORT_METHOD(openDocument:(NSString*)uri scheme:(NSString *)scheme name:(NSString*)name resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
540540
{
541541
NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
542542
NSURL * url = [[NSURL alloc] initWithString:utf8uri];
543543
// NSURL * url = [[NSURL alloc] initWithString:uri];
544544
documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
545545
documentController.delegate = self;
546+
documentController.name = name;
546547

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

0 commit comments

Comments
 (0)