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:
{ success: true, ...result }
{ success: false, code: 'ERROR_CODE', error: 'Message', details: { ... } }Properties
| Property | Value |
|---|---|
wapp.isNativeApp | true inside the app |
wapp.bridgeVersion | The 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.
const info = await wapp.deviceInfo();| Field | Description |
|---|---|
platform | 'ios' or 'android' |
osVersion | Operating system version |
appVersion, buildNumber | Your app's version and build number |
appId | Bundle identifier or package name |
model, manufacturer | Device model (Android) and manufacturer |
isTablet | true on tablets |
language, timeZone | The device's locale settings |
installationId | A random ID created on first use and removed with the app (not an advertising ID) |
plugins | IDs of the plugins usable right now |
bridgeVersion | The bridge version |
wapp.permissions.request(name)
Asks for a device permission, following the prompt settings in the dashboard.
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 alsomotionandtrackingTransparency; Android alsostorage.status:granted,limited,denied,blocked(denied permanently; only the system settings can change it) orunavailable.configured:falsewhen 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.
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.
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:
// { success: true, plugins: [ { id: 'haptics', enabled: true }, { id: 'iap', enabled: false, reason: 'not_in_build' } ] }Plugin namespaces
| Namespace | Methods | Guide |
|---|---|---|
wapp.barcode | scan, setPrompt | Barcode scanner |
wapp.haptics | trigger | Haptics |
wapp.appReview | prompt, openStoreListing | App Review |
wapp.calendar | addEvent, importIcs | Calendar |
wapp.contacts | pickContact, getPermissionStatus, getAll | Contacts |
wapp.share | getReceived, clearReceived | Share into App |
wapp.backgroundLocation | start, stop, status | Background Location |
wapp.socialLogin.apple / .google / .facebook | login, logout | Social login |
wapp.iap | info, purchase, purchases, restorePurchases, finish, manageSubscription, manageAllSubscriptions | In-app purchases |
wapp.revenueCat | getOfferings, purchasePackage, getCustomerInfo, restorePurchases, logIn, logOut, manageSubscriptions | In-app purchases |
wapp.firebaseAnalytics | logEvent, logScreen, setUser, setUserProperty, setConsent, collection, defaultEventParameters, e-commerce events | Firebase Analytics |
wapp.crashlytics | log, recordError, setUserId, unsetUserId, setAttribute, enable, webErrorLogsEnabled | Crashlytics |
wapp.commerce | cartUpdated, openScreen | Shopify |
Error codes
| Code | Meaning | What to do |
|---|---|---|
PLUGIN_NOT_ENABLED | The plugin is off, not in your plan, or not in this build. details.reason says which. | Turn it on and build again |
PERMISSION_DENIED | The user or the system refused access | Explain and offer the settings |
UNSUPPORTED_PLATFORM | Not available on this platform | Hide the feature on that platform |
UNSUPPORTED_OPTION | An option is not supported yet | Remove the option |
INVALID_PARAMS | A parameter is wrong; details.field names it | Fix the call |
UNKNOWN_METHOD | The method does not exist in this app build | Check the name; update the app |
CANCELLED | The user closed the native screen | Usually nothing |
BUSY | Another call of the same plugin is open | Wait for the first call |
TIMEOUT | The app did not answer in time | Try again |
BRIDGE_NOT_ALLOWED | This page may not use the bridge | See Website access |
NOT_CONFIGURED | A required setting or device feature is missing | Complete the plugin setup |
AUTH_FAILED | A sign-in or biometric check failed | Let the user try again |
RATE_LIMITED | Too many calls in a short time | Slow down |
NATIVE_ERROR | The app could not complete the call | Try again; report if it persists |