NFC Bridge
Bridge for reading NFC tags from website JavaScript through the native MobiWeb wrapper.
Android
Bridge object: NfcBridge
Methods
Method | Return | Description |
|---|
isAvailable()
| boolean
| Returns whether NFC hardware is present and enabled |
startScan()
| void
| Starts reader mode and emits NFC tag events |
stopScan()
| void
| Stops reader mode and clears active scan state |
writeNdef(payload)
| void
| Placeholder for write support; returns a failure event for now |
Events
Event name | event.detail shape
| Description |
|---|
mobiweb:nfcScanStarted
| { started: boolean }
| Reader mode started |
mobiweb:nfcScanResumed
| { resumed: boolean }
| Reader mode resumed after app foregrounded |
mobiweb:nfcScanStopped
| { stopped: boolean }
| Reader mode stopped |
mobiweb:nfcTag
| { id: string }
| NFC tag identifier in hex |
mobiweb:nfcError
| { message: string }
| NFC error state |
mobiweb:nfcWriteResult
| { success: boolean, message?: string }
| Write placeholder result |
Example
if (typeof NfcBridge !== 'undefined' && NfcBridge.isAvailable()) {
NfcBridge.startScan();
}
window.addEventListener('mobiweb:nfcTag', (event) => {
console.log('Tag ID:', event.detail.id);
});
window.addEventListener('mobiweb:nfcError', (event) => {
console.error('NFC error:', event.detail.message);
});
iOS
Bridge object: AppleNFC
Methods
Method | Return | Description |
|---|
isAvailable()
| boolean
| Returns whether CoreNFC reading is available |
startScan()
| Promise<void>
| Starts an NFCNDEFReaderSession |
stopScan()
| Promise<void>
| Stops the active session |
writeNdef(payload)
| Promise<void>
| Placeholder for write support; returns failure for now |
Events
Event name | event.detail shape
| Description |
|---|
mobiweb:nfcStatus
| { action: string, success: boolean, error?: string }
| Start/stop/write status |
mobiweb:nfcTag
| { records: Array<object> }
| Read NDEF records |
mobiweb:nfcError
| { message: string }
| NFC error state |
Example
if (window.AppleNFC && AppleNFC.isAvailable()) {
AppleNFC.startScan()
.then(() => console.log('NFC scan started'))
.catch((error) => console.error('Start failed:', error.message));
}
window.addEventListener('mobiweb:nfcTag', (event) => {
console.log('NDEF records:', event.detail.records);
});
function startNfcScan() {
if (typeof NfcBridge !== 'undefined') {
return NfcBridge.startScan();
}
if (typeof AppleNFC !== 'undefined') {
return AppleNFC.startScan();
}
throw new Error('NFC bridge not available');
}
06 May 2026