Référence du Bridge
Le Bridge expose window.PWA2APP à votre page, sur votre origine autorisée. Le SDK @pwa2app/bridge l'enveloppe avec des types et des replis web.
Fonctionnalités activables
Une méthode liée à une fonctionnalité n'existe que si elle est activée dans la configuration de l'application ; sinon l'appel renvoie NOT_ENABLED.
camera photos location files clipboard notifications biometric vibration
Méthodes
| Méthode | Fonctionnalité | Appels/s | Paramètres | Résultat |
|---|---|---|---|---|
bridge.handshake | toujours active | 5 | — | protocol_versions, runtime_version, platform, enabled_features |
device.info | toujours active | 5 | — | platform, os_version, sdk_int, manufacturer, model, app_version, runtime_version |
device.vibrate | vibration | 5 | pattern : array ≤ 20 éléments | — |
network.status | toujours active | 5 | — | online, type |
app.version | toujours active | 5 | — | version_name, version_code |
app.openSettings | toujours active | 2 | — | — |
app.exit | toujours active | 1 | — | — |
statusBar.setStyle | toujours active | 5 | style : "light" | "dark" | — |
statusBar.setColor | toujours active | 5 | color : string | — |
haptics.impact | toujours active | 10 | style : "light" | "medium" | "heavy" | — |
share.share | toujours active | 2 | title : string ≤ 200 car.text : string ≤ 5000 car.url : string ≤ 2000 car. | shared |
clipboard.readText | clipboard | 1 | — | text |
clipboard.writeText | clipboard | 5 | text : string ≤ 100000 car. | — |
location.getCurrent | location | 2 | precision : "approximate" | "precise"timeout_ms : integer [1000…60000] | lat, lng, accuracy_m, timestamp |
location.watch | location | 1 | precision : "approximate" | "precise"interval_ms : integer [1000…600000] | watch_id |
location.clearWatch | location | 5 | watch_id : string | — |
camera.capture | camera | 2 | quality : number [0.1…1]max_size_px : integer [200…4096] | mime, data_base64, width, height, size |
camera.pickImage | photos | 2 | quality : number [0.1…1]max_size_px : integer [200…4096] | mime, data_base64, width, height, size |
files.pick | files | 2 | mime_types : array ≤ 10 éléments | name, mime, size, data_base64 |
files.save | files | 2 | name : string ≤ 100 car.mime : stringdata_base64 : string | saved |
files.share | files | 2 | name : string ≤ 100 car.mime : stringdata_base64 : string | shared |
notifications.requestPermission | notifications | 2 | — | granted |
notifications.getToken | notifications | 2 | — | NOT_SUPPORTED en V1 Android (FCM non embarqué) |
notifications.schedule | notifications | 5 | id : stringtitle : string ≤ 100 car.body : string ≤ 500 car.delay_ms : integer [0…] | id |
notifications.cancel | notifications | 5 | id : string | — |
biometric.isAvailable | biometric | 2 | — | available |
biometric.authenticate | biometric | 1 | reason : string ≤ 200 car. | authenticated |
Codes d'erreur du Bridge
NOT_SUPPORTED NOT_ENABLED PERMISSION_DENIED INVALID_PARAMS ORIGIN_NOT_ALLOWED RATE_LIMITED CANCELLED TIMEOUT INTERNAL VERSION_MISMATCH
Événements
network.change— { online, type } — changement de connectivitélocation.update— { watch_id, lat, lng, accuracy_m, timestamp } — position d'une surveillancenotification.opened— { id } — notification locale touchéeapp.resume— {} — application revenue au premier planapp.pause— {} — application passée en arrière-plan
Exemple
import { PWA2APP } from "@pwa2app/bridge";
if (PWA2APP.isNative()) {
const position = await PWA2APP.location.getCurrent({ precision: "approximate" });
console.log(position.lat, position.lng);
}SDK : dossier bridge/javascript du projet ; dans un navigateur normal, les fonctions avec équivalent web l'utilisent.