@martinbuezas/nativescript-share-file
by martinbuezas | v3.0.0
Nativescript 分享文件插件
npm i --save @martinbuezas/nativescript-share-file

@martinbuezas/nativescript-share-file

ns plugin add @martinbuezas/nativescript-share-file

向其他应用发送/分享文件。

Android 意图, IOS InteractionController

.

用法

信息:共享文件应在 documents 路径中。

    import { ShareFile } from 'nativescript-share-file';
import * as fs from 'tns-core-modules/file-system';

export class TestClass{

shareFile;
fileName;
documents;
path;
file;

constructor() {

this.fileName = 'text.txt';
this.documents = fs.knownFolders.documents();
this.path = fs.path.join(this.documents.path, this.fileName);
this.file = fs.File.fromPath(this.path);
this.shareFile = new ShareFile();

this.shareFile.open( {
path: this.path,
intentTitle: 'Open text file with:', // optional Android
rect: { // optional iPad
x: 110,
y: 110,
width: 0,
height: 0
},
options: true, // optional iOS
animated: true // optional iOS
});
}
}

参数

path

要共享的文件的路径。

String:必需

intentTitle

Android 上意图的标题。

String:(可选) 默认:Open file:

rect

用于 iPad 的视图定位。在 iPhone 上它总是显示在底部。

Object:(可选) 默认:{x: 0, y: 0, width: 0, height: 0 }

options

显示 iOS 设备的附加打开选项。

Boolean:(可选) 默认:false

animated

用于 iOS 设备的打开动画。

Boolean:(可选) 默认:false

许可证

Apache 许可证版本 2.0