Skip to main content

document-viewer API

Type Aliases

BaseOptions

BaseOptions: {grantPermissions: "read" | "write";headerTitle: string;mimeType: string;presentationStyle: PresentationStyle; }

Type declaration

NameTypeDescription
grantPermissions?"read" | "write"Android only: The type of permission to grant to the receiving app that will open the document. This only has effect if you're viewing a file that lives in the app's sandboxed storage.
headerTitle?stringiOS only: The title to display in the header of the document viewer. If not provided, the filename will be used.
mimeType?stringOptional, but recommended: the mimetype of the document. This will help the Android OS to find the right app(s) to open the document.
presentationStyle?PresentationStyleiOS only - Controls how the picker is presented, e.g. on an iPad you may want to present it fullscreen. Defaults to pageSheet.

OptionsViewBookmark

OptionsViewBookmark: BaseOptions & {bookmark: string; }

BaseOptions with the bookmark data from the DocumentPicker module. Obtain the bookmark using the "open" mode, with requestLongTermAccess flag set to true.

A bookmark enables long-term access to a file.

Type declaration

NameTypeDescription
bookmarkstringbookmark data from the DocumentPicker module. Obtain it using the "open" mode, with requestLongTermAccess flag set to true. A bookmark allows a long-term permission to access a file.

OptionsViewUri

OptionsViewUri: BaseOptions & {uri: string; }

BaseOptions with the uri of the document to view

Type declaration

NameTypeDescription
uristringThe uri of the document to view

PresentationStyle

PresentationStyle: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen" | undefined

iOS only. Configure the presentation style of the picker.


ViewDocumentOptions

ViewDocumentOptions: OptionsViewBookmark | OptionsViewUri

options for viewing a document

If you're trying to open a file that you have long-term permission to access, you should use the bookmark option (provided by the DocumentPicker module).

Variables

errorCodes

const errorCodes: Readonly<{IN_PROGRESS: "ASYNC_OP_IN_PROGRESS";OPERATION_CANCELED: "OPERATION_CANCELED";UNABLE_TO_OPEN_FILE_TYPE: "UNABLE_TO_OPEN_FILE_TYPE"; }>

Type declaration

NameType
IN_PROGRESS"ASYNC_OP_IN_PROGRESS"
OPERATION_CANCELED"OPERATION_CANCELED"
UNABLE_TO_OPEN_FILE_TYPE"UNABLE_TO_OPEN_FILE_TYPE"

Functions

isErrorWithCode()

isErrorWithCode(error: any): error is NativeModuleError

TypeScript helper to check if an object has the code property. This is used to avoid as casting when you access the code property on errors returned by the module.

Parameters

ParameterType
errorany

Returns

error is NativeModuleError


viewDocument()

viewDocument(data: ViewDocumentOptions): Promise<null>

Parameters

ParameterType
dataViewDocumentOptions

Returns

Promise<null>