Skip to main content
JavaScript Bridge3 min read

JavaScript Bridge API Reference

Reference for the WebAppStudio JavaScript Bridge: properties, core methods, plugin namespaces, result format and every error code.

Overview

Core methods are available in every app. Plugin methods work once the plugin is turned on and the app has been built with it; otherwise they answer PLUGIN_NOT_ENABLED.

All methods return a promise that never rejects:

javascript
{ success: true, ...result }
{ success: false, code: 'ERROR_CODE', error: 'Message', details: { ... } }

Properties

PropertyValue
wapp.isNativeApptrue inside the app
wapp.bridgeVersionThe bridge version of this app build
wapp.on(name, handler)Subscribes to an event and returns a function that unsubscribes. See Events.

Core methods

wapp.deviceInfo()

Information about the device and the app.

javascript
const info = await wapp.deviceInfo();
FieldDescription
platform'ios' or 'android'
osVersionOperating system version
appVersion, buildNumberYour app's version and build number
appIdBundle identifier or package name
model, manufacturerDevice model (Android) and manufacturer
isTablettrue on tablets
language, timeZoneThe device's locale settings
installationIdA random ID created on first use and removed with the app (not an advertising ID)
pluginsIDs of the plugins usable right now
bridgeVersionThe bridge version

wapp.permissions.request(name)

Asks for a device permission, following the prompt settings in the dashboard.

javascript
const result = await wapp.permissions.request('camera');
// { success: true, permission: 'camera', status: 'granted', configured: true }
  • name: camera, microphone, photos, location, contacts, calendar, bluetooth, biometric, notifications; iOS also motion and trackingTransparency; Android also storage.
  • status: granted, limited, denied, blocked (denied permanently; only the system settings can change it) or unavailable.
  • configured: false when the permission is not turned on in this app build. Turn it on in Permissions › Device and build again.

wapp.permissions.status(name)

Reads the current status without asking: { success: true, permission, status }.

wapp.biometrics.authenticate(options)

Face ID, Touch ID or fingerprint. Needs Biometric Authentication in Permissions › Device.

javascript
const result = await wapp.biometrics.authenticate({ reason: 'Confirm it is you' });
// success: { success: true, status: 'authenticated' }

reason is optional (up to 200 characters). Failures: CANCELLED, AUTH_FAILED, NOT_CONFIGURED. See Biometric authentication.

wapp.share.open(options)

Opens the native share sheet.

javascript
await wapp.share.open({ title: 'My store', text: 'Look at this', url: 'https://example.com/item' });

Give text or url (http or https). Sharing files is not supported yet. The result is { status: 'shared' }, with activityType on iOS when reported. On iOS, closing the sheet answers CANCELLED; Android cannot tell, so it always reports shared. Inside the app, navigator.share() uses the same sheet on both platforms.

wapp.plugins.list()

The plugins known to this app and their state:

javascript
// { success: true, plugins: [ { id: 'haptics', enabled: true }, { id: 'iap', enabled: false, reason: 'not_in_build' } ] }

Plugin namespaces

NamespaceMethodsGuide
wapp.barcodescan, setPromptBarcode scanner
wapp.hapticstriggerHaptics
wapp.appReviewprompt, openStoreListingApp Review
wapp.calendaraddEvent, importIcsCalendar
wapp.contactspickContact, getPermissionStatus, getAllContacts
wapp.sharegetReceived, clearReceivedShare into App
wapp.backgroundLocationstart, stop, statusBackground Location
wapp.socialLogin.apple / .google / .facebooklogin, logoutSocial login
wapp.iapinfo, purchase, purchases, restorePurchases, finish, manageSubscription, manageAllSubscriptionsIn-app purchases
wapp.revenueCatgetOfferings, purchasePackage, getCustomerInfo, restorePurchases, logIn, logOut, manageSubscriptionsIn-app purchases
wapp.firebaseAnalyticslogEvent, logScreen, setUser, setUserProperty, setConsent, collection, defaultEventParameters, e-commerce eventsFirebase Analytics
wapp.crashlyticslog, recordError, setUserId, unsetUserId, setAttribute, enable, webErrorLogsEnabledCrashlytics
wapp.commercecartUpdated, openScreenShopify

Error codes

CodeMeaningWhat to do
PLUGIN_NOT_ENABLEDThe plugin is off, not in your plan, or not in this build. details.reason says which.Turn it on and build again
PERMISSION_DENIEDThe user or the system refused accessExplain and offer the settings
UNSUPPORTED_PLATFORMNot available on this platformHide the feature on that platform
UNSUPPORTED_OPTIONAn option is not supported yetRemove the option
INVALID_PARAMSA parameter is wrong; details.field names itFix the call
UNKNOWN_METHODThe method does not exist in this app buildCheck the name; update the app
CANCELLEDThe user closed the native screenUsually nothing
BUSYAnother call of the same plugin is openWait for the first call
TIMEOUTThe app did not answer in timeTry again
BRIDGE_NOT_ALLOWEDThis page may not use the bridgeSee Website access
NOT_CONFIGUREDA required setting or device feature is missingComplete the plugin setup
AUTH_FAILEDA sign-in or biometric check failedLet the user try again
RATE_LIMITEDToo many calls in a short timeSlow down
NATIVE_ERRORThe app could not complete the callTry again; report if it persists

Next steps