PWA2APP Documentation

Bridge reference

The Bridge exposes window.PWA2APP to your page, on your allowed origin. The @pwa2app/bridge SDK wraps it with types and web fallbacks.

Optional features

A method tied to a feature only exists if it is enabled in the application's configuration; otherwise the call returns NOT_ENABLED.

camera photos location files clipboard notifications biometric vibration

Methods

MethodFeatureCalls/sParametersResult
bridge.handshakealways available5—protocol_versions, runtime_version, platform, enabled_features
device.infoalways available5—platform, os_version, sdk_int, manufacturer, model, app_version, runtime_version
device.vibratevibration5pattern : array ≤ 20 éléments—
network.statusalways available5—online, type
app.versionalways available5—version_name, version_code
app.openSettingsalways available2——
app.exitalways available1——
statusBar.setStylealways available5style : "light" | "dark"—
statusBar.setColoralways available5color : string—
haptics.impactalways available10style : "light" | "medium" | "heavy"—
share.sharealways available2title : string ≤ 200 car.
text : string ≤ 5000 car.
url : string ≤ 2000 car.
shared
clipboard.readTextclipboard1—text
clipboard.writeTextclipboard5text : string ≤ 100000 car.—
location.getCurrentlocation2precision : "approximate" | "precise"
timeout_ms : integer [1000…60000]
lat, lng, accuracy_m, timestamp
location.watchlocation1precision : "approximate" | "precise"
interval_ms : integer [1000…600000]
watch_id
location.clearWatchlocation5watch_id : string—
camera.capturecamera2quality : number [0.1…1]
max_size_px : integer [200…4096]
mime, data_base64, width, height, size
camera.pickImagephotos2quality : number [0.1…1]
max_size_px : integer [200…4096]
mime, data_base64, width, height, size
files.pickfiles2mime_types : array ≤ 10 élémentsname, mime, size, data_base64
files.savefiles2name : string ≤ 100 car.
mime : string
data_base64 : string
saved
files.sharefiles2name : string ≤ 100 car.
mime : string
data_base64 : string
shared
notifications.requestPermissionnotifications2—granted
notifications.getTokennotifications2—NOT_SUPPORTED en V1 Android (FCM non embarqué)
notifications.schedulenotifications5id : string
title : string ≤ 100 car.
body : string ≤ 500 car.
delay_ms : integer [0…]
id
notifications.cancelnotifications5id : string—
biometric.isAvailablebiometric2—available
biometric.authenticatebiometric1reason : string ≤ 200 car.authenticated

Bridge error codes

NOT_SUPPORTED NOT_ENABLED PERMISSION_DENIED INVALID_PARAMS ORIGIN_NOT_ALLOWED RATE_LIMITED CANCELLED TIMEOUT INTERNAL VERSION_MISMATCH

Events

  • network.change — { online, type } — changement de connectivité
  • location.update — { watch_id, lat, lng, accuracy_m, timestamp } — position d'une surveillance
  • notification.opened — { id } — notification locale touchée
  • app.resume — {} — application revenue au premier plan
  • app.pause — {} — application passée en arrière-plan

Example

import { PWA2APP } from "@pwa2app/bridge";

if (PWA2APP.isNative()) {
  const position = await PWA2APP.location.getCurrent({ precision: "approximate" });
  console.log(position.lat, position.lng);
}

SDK: bridge/javascript folder of the project; in a regular browser, functions with a web equivalent use it.