AR Defence Documentation
Learn
AR Defence / Browser Integration / Bridge Wiki

Bridge Function Wiki

Reference for the browser bridge used inside the AR Defence host app. This page is structured like product documentation: setup, function reference, event reference, resolver responsibility, and implementation patterns.

Setup

Pick one integration mode. For most websites, use ar-web-bridge. For SPA / PWA apps that want raw events and custom resolver control, use ar-host-sdk.

Regular Website: `ar-web-bridge`

<script>
  window.AR_CONFIG = {
    gatewayUrl: "https://customer.example.com/personnel/resolve",
  };
</script>
<script src="https://cdn.ar-defense.com/ar-web-bridge/0.1.0/ar-web-bridge.bundle.js"></script>

SPA / PWA: `ar-host-sdk`

<script src="https://cdn.ar-defense.com/ar-host-sdk/0.1.0/ar-host-sdk.js"></script>
<script>
  const resolveTag = window.ARHostSDK.createGatewayPersonnelResolver({
    gatewayUrl: "https://customer.example.com/personnel/resolve",
  });

  window.AR = window.ARHostSDK.createBridge({ resolveTag });
</script>

Bridge Surface

The browser contract is intentionally small. The host app reads raw RFID / NFC / QR values and the browser app decides how to use them.

Area Functions Result
RFID startRfidScan(), stopRfidScan() Emits rfid.epc and optionally rfid.personnel
NFC startNfcScan(), stopNfcScan() Emits nfc.uid and optionally nfc.personnel
QR startQrScan() Emits qr.value or qr.cancelled
Host getHostInfo(), on(...) Reads host metadata and subscribes to events

RFID Functions

Use RFID for crew-level or batch flows. The host app emits raw EPC reads. Name resolution is not performed in the host app.

startRfidScan()

async

Starts the native RFID reader. The browser should listen for rfid.epc and optionally rfid.personnel.

async function beginCrewScan() {
  await window.AR.stopNfcScan();
  await window.AR.startRfidScan();
}

stopRfidScan()

async

Stops the native RFID session. Call this when leaving the screen or changing to a different scan mode.

async function endCrewScan() {
  await window.AR.stopRfidScan();
}

NFC Functions

Use NFC for individual tags, personal cards, or single-member confirmation flows.

startNfcScan()

async

Starts the native NFC session. The browser should listen for nfc.uid and optionally nfc.personnel.

async function beginPersonalScan() {
  await window.AR.stopRfidScan();
  await window.AR.startNfcScan();
}

stopNfcScan()

async

Stops the native NFC session. Call this after receiving the accepted tag or when leaving the personal scan screen.

async function endPersonalScan() {
  await window.AR.stopNfcScan();
}

QR Functions

QR scanning is host-native. Typical use is provisioning or assigning a printed RFID label to a selected member.

startQrScan()

async

Opens the host-native QR flow. The result is returned by events, not by the function return value.

async function assignByQr(member) {
  selectedMember = member;
  await window.AR.startQrScan();
}

window.AR.on("qr.value", (value) => {
  assignRfidTagToMember(selectedMember, value);
});

Host Functions

Use host functions to read runtime metadata and to subscribe to bridge events.

getHostInfo()

async

Requests a host snapshot. The host answers through the host.info event.

window.AR.on("host.info", (info) => {
  console.log(info.embeddedAppUrl);
  console.log(info.rfid?.state);
});

await window.AR.getHostInfo();

on(eventName, handler)

subscription

Registers an event listener and returns an unsubscribe function.

const off = window.AR.on("rfid.personnel", (person) => {
  addMember(person);
});

// later
off();

Events

Use raw events if you want your own lookup flow. Use personnel events if the resolver is configured.

Event Payload Meaning
rfid.epc Raw EPC string Host app read an RFID tag. No names are resolved in the host app.
rfid.personnel "ID - Name" Resolver mapped the EPC to a person.
nfc.uid Raw UID string Host app read an NFC tag. No names are resolved in the host app.
nfc.personnel "ID - Name" Resolver mapped the NFC UID to a person.
qr.value String QR scan succeeded.
qr.cancelled null QR flow closed without result.
host.info Host-defined object Version, runtime, selected embedded URL, and capability snapshot.
ar.error { source, code, message, timestamp } Bridge, host, scan, or resolver error.

Gateway Resolver

Name resolution belongs in the gateway. The host app should only emit EPC and UID values.

createGatewayPersonnelResolver({ gatewayUrl })

helper

This helper POSTs the raw tag to the configured backend and converts the response into the bridge personnel label.

const resolveTag = window.ARHostSDK.createGatewayPersonnelResolver({
  gatewayUrl: "https://customer.example.com/personnel/resolve",
});

window.AR = window.ARHostSDK.createBridge({ resolveTag });
Resolver responsibility

Production integrations should point the resolver to the customer backend. Mapping raw RFID and NFC identifiers to people is a backend responsibility.

Usage Patterns

These are the three common integration flows used by customers.

Crew RFID Scan

window.AR.on("rfid.personnel", (person) => {
  addMemberToCrew(person);
});

await window.AR.startRfidScan();

Personal NFC Scan

window.AR.on("nfc.personnel", (person) => {
  setSingleMember(person);
});

await window.AR.startNfcScan();

QR Assignment

await window.AR.startQrScan();

window.AR.on("qr.value", (value) => {
  saveAssignedTag(value);
});

Operational Notes

  • Auth is independent from the host app. Popup, redirect, backend session, or another IdP are all valid.
  • The host app emits raw scan identifiers only. Business resolution belongs in the gateway.
  • Pin customer integrations to explicit bridge versions from the CDN.