Skip to content

UI

Public surface (ui): openPDF · showToolbar · openVideo

openPDF(pdfPath: string, title: string, customOptions?: Record<string, unknown>): void
Environment Behavior
Native app (isApp()) Analytics event method showpdf → host PDF viewer
Browser window.open(pdfPath, '_blank')
import mobilelocker from '@mobilelocker/javascript-sdk'
mobilelocker.ui.openPDF('/files/brochure.pdf', 'Product Brochure')
showToolbar(): void
// Throws UnsupportedEnvironment outside iOS
if (mobilelocker.isIOS()) {
mobilelocker.ui.showToolbar()
}
openVideo(path: string, options?: VideoOptions): Promise<VideoResult>
interface VideoOptions {
autoplay?: boolean
loop?: boolean
muted?: boolean
startTime?: number
endTime?: number
rate?: number
showControls?: boolean
allowScrubbing?: boolean
allowedSpeeds?: number[]
allowPiP?: boolean
allowAirPlay?: boolean
allowFullscreen?: boolean
title?: string
videoGravity?: 'fit' | 'fill' | 'stretch'
}
// VideoResult = WithStatusBooleans<
// | { status: 'completed'; position: number }
// | { status: 'dismissed'; position: number }
// | { status: 'failed'; error: string }
// >
// booleans: isCompleted, isDismissed, isFailed
Environment Behavior
iOS Native AVPlayer via host
Other Full-viewport <video> overlay (click outside to dismiss)
const result = await mobilelocker.ui.openVideo('/files/demo.mp4', {
autoplay: true,
showControls: true,
})
if (result.isCompleted || result.status === 'completed') {
console.log(`Watched to ${result.position}s`)
}