forked from RonRadtke/react-native-blob-util
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ios.js
62 lines (55 loc) · 2.28 KB
/
ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2016 wkh237@github. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
import { NativeModules, Platform } from "react-native";
const ReactNativeBlobUtil: ReactNativeBlobUtilNative = NativeModules.ReactNativeBlobUtil;
/**
* Displays an options menu using UIDocumentInteractionController.presentOptionsMenu
* @param {string} path Path of the file to be open.
* @param {string} scheme URI scheme that needs to support, optional
* @return {Promise}
*/
function presentOptionsMenu(path: string, scheme: string) {
if (Platform.OS === "ios")
return ReactNativeBlobUtil.presentOptionsMenu("file://" + path, scheme);
else return Promise.reject("ReactNativeBlobUtil.openDocument only supports IOS.");
}
/**
* Displays a menu for opening the document using UIDocumentInteractionController.presentOpenInMenu
* @param {string} path Path of the file to be open.
* @param {string} scheme URI scheme that needs to support, optional
* @return {Promise}
*/
function presentOpenInMenu(path: string, scheme: string) {
if (Platform.OS === "ios")
return ReactNativeBlobUtil.presentOpenInMenu("file://" + path, scheme);
else return Promise.reject("ReactNativeBlobUtil.openDocument only supports IOS.");
}
/**
* Displays a full-screen preview of the target document using UIDocumentInteractionController.presentPreview
* @param {string} path Path of the file to be open.
* @param {string} scheme URI scheme that needs to support, optional
* @return {Promise}
*/
function presentPreview(path: string, scheme: string) {
if (Platform.OS === "ios")
return ReactNativeBlobUtil.presentPreview("file://" + path, scheme);
else return Promise.reject("ReactNativeBlobUtil.previewDocument only supports IOS.");
}
/**
* Set excludeFromBackupKey to a URL to prevent the resource to be backuped to
* iCloud.
* @param {string} url URL of the resource, only file URL is supported
* @return {Promise}
*/
function excludeFromBackupKey(path: string) {
return ReactNativeBlobUtil.excludeFromBackupKey("file://" + path);
}
export default {
presentPreview,
openDocument: presentPreview, // legacy alias
presentOptionsMenu,
previewDocument: presentOptionsMenu, // legacy alias
presentOpenInMenu,
excludeFromBackupKey
};