Skip to content

Environments

Use environment helpers to branch UI and to avoid calling APIs that only exist on certain hosts.

These are top-level functions on the default export and as named exports (not under a domain object).

Helper True when
isMobileLocker() Any Mobile Locker app or CDN presentation context
isApp() iOS, Android, or Windows native shell
isIOS() Mobile Locker iOS / iPadOS app
isAndroid() Mobile Locker Android app
isWindows() Mobile Locker Windows app (includes the legacy Electron Windows shell)
isCDN() CDN-hosted presentation URL
isElectron() Legacy Electron Windows shell
import mobilelocker from '@mobilelocker/javascript-sdk'
// or: import { isIOS, isWindows, isApp, isMobileLocker } from '@mobilelocker/javascript-sdk'
mobilelocker.isMobileLocker()
mobilelocker.isApp()
mobilelocker.isIOS()
mobilelocker.isAndroid()
mobilelocker.isWindows()
mobilelocker.isCDN()
mobilelocker.isElectron()
import mobilelocker from '@mobilelocker/javascript-sdk'
async function openScannerIfPossible(eventID) {
// scanBadge / scanBusinessCard throw UnsupportedEnvironment outside iOS
if (!mobilelocker.isIOS()) {
console.info('Scanner is iOS-only')
return null
}
return mobilelocker.scanner.scanBadge(eventID)
}
async function fetchRemote(url) {
// In the native app (isApp), http.* is proxied (no CORS). On CDN/browser, fetch CORS rules apply.
return mobilelocker.http.get(url)
}
// device.get(): Promise<DeviceInfo | null> — iOS and Android only; null elsewhere
// device.isAtLeastVersion(version: string): Promise<boolean> — false outside iOS/Android
if (mobilelocker.isApp() && (await mobilelocker.device.isAtLeastVersion('5.5.0'))) {
// Contacts/CRM cursor list APIs and other host features that need a minimum version
}

Use device.isAtLeastVersion when you need to gate on a specific host capability. Documented cursor list APIs require iOS 5.5.0+.

Local development in a normal browser: most bridge calls no-op or return local fallbacks so presentations can still load. Prefer isMobileLocker() before assuming host data is real.