unfc
Version:
A framework-agnostic NFC package for reading/writing NFC tags in web apps and PWAs
40 lines (39 loc) • 1.26 kB
TypeScript
import { NdefRecord, NdefMessage } from "./definitions.js";
export declare class NfcUtils {
/**
* Creates a simple text record
*/
static createTextRecord(text: string, languageCode?: string): NdefRecord;
/**
* Creates a URI/URL record
*/
static createUriRecord(uri: string): NdefRecord;
/**
* Creates a complete NDEF message with one or more records
*/
static createMessage(records: NdefRecord[]): NdefMessage;
/**
* Extract text content from detected tag
* Returns the first text record found or null if none
*/
static getTextFromTag(tag: {
messages: NdefMessage[];
}): string | null;
/**
* Extract URL/URI from detected tag
* Returns the first URL record found or null if none
*/
static getUrlFromTag(tag: {
messages: NdefMessage[];
}): string | null;
/**
* Checks if this browser environment supports Web NFC
*/
static isWebNfcSupported(): boolean;
/**
* Checks if the device is likely to have NFC hardware
* (Not 100% reliable but useful as a hint)
*/
static isNfcLikelyAvailable(): boolean;
}
export declare function formatData(data: string): string;