Skip to main content

document-viewer API

Type Aliases​

BaseOptions​

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

Properties​

androidApplicationId?​

optional androidApplicationId: string

Android only - Optional, only provide a value if calling viewDocument rejects with IllegalArgumentException. Represents the unique identifier for an Android application. Defaults to application package name, which usually is the same as the application id.

grantPermissions?​

optional grantPermissions: "read" | "write"

Android only: The type of permission to grant to the receiving app that will open the document. This only has an effect if you're viewing a file that lives in the app's sandboxed storage.

headerTitle?​

optional headerTitle: string

iOS only: The title to display in the header of the document viewer.

Default​
the file name.
mimeType?​

optional mimeType: string

Optional, but strongly recommended: the mimetype of the document. This helps the Android OS to find the right app(s) to open the document.

presentationStyle?​

optional presentationStyle: PresentationStyle

iOS only - Controls how the picker is presented, e.g. on an iPad you may want to present it fullscreen.

Default​

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<{ NULL_PRESENTER: "NULL_PRESENTER"; UNABLE_TO_OPEN_FILE_TYPE: "UNABLE_TO_OPEN_FILE_TYPE"; }>

Functions​

isErrorWithCode()​

isErrorWithCode(error: unknown): 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
errorunknown

Returns​

error is NativeModuleError


viewDocument()​

viewDocument(data: ViewDocumentOptions): Promise<null>

Parameters​

ParameterType
dataViewDocumentOptions

Returns​

Promise<null>