77 lines
2.7 KiB
TypeScript
77 lines
2.7 KiB
TypeScript
import { IsEnabledResult, NfcStatusChangedEvent, StartScanSessionOptions, TagDetectedEvent, WriteOptions, ShareOptions, PluginListenerHandle } from "./definitions.js";
|
|
/**
|
|
* Main NFC class that provides access to NFC functionality.
|
|
* It automatically chooses the appropriate implementation for the current platform.
|
|
*/
|
|
export declare class Nfc {
|
|
private implementation;
|
|
private listeners;
|
|
constructor();
|
|
/**
|
|
* Internal method to monitor NFC status changes
|
|
*/
|
|
private monitorNfcStatus;
|
|
/**
|
|
* Check if NFC is enabled (Android) or available (iOS/Web).
|
|
* @returns Promise resolving to an object with an `enabled` boolean property
|
|
*/
|
|
isEnabled(): Promise<IsEnabledResult>;
|
|
/**
|
|
* Open NFC settings (Android) or app settings (iOS) or shows guidance (Web).
|
|
* This helps users enable NFC if it's disabled.
|
|
*/
|
|
openSettings(): Promise<void>;
|
|
/**
|
|
* Start scanning for NFC tags.
|
|
* @param options Configuration options for the scan session
|
|
*/
|
|
startScanSession(options?: StartScanSessionOptions): Promise<void>;
|
|
/**
|
|
* Stop the current NFC scan session.
|
|
*/
|
|
stopScanSession(): Promise<void>;
|
|
/**
|
|
* Write an NDEF message to an NFC tag.
|
|
* @param options Object containing the NDEF message to write
|
|
*/
|
|
write(options: WriteOptions): Promise<void>;
|
|
/**
|
|
* Make an NFC tag read-only.
|
|
* WARNING: This is a permanent operation that cannot be undone.
|
|
*/
|
|
makeReadOnly(): Promise<void>;
|
|
/**
|
|
* Format an NFC tag, erasing its contents and preparing it for writing.
|
|
*/
|
|
format(): Promise<void>;
|
|
/**
|
|
* Erase the contents of an NFC tag.
|
|
*/
|
|
erase(): Promise<void>;
|
|
/**
|
|
* Share NDEF data via NFC (Android only, not available on iOS or Web).
|
|
* @param options Object containing the NDEF message to share
|
|
*/
|
|
share(options: ShareOptions): Promise<void>;
|
|
/**
|
|
* Stop sharing NDEF data via NFC (Android only).
|
|
*/
|
|
stopSharing(): Promise<void>;
|
|
/**
|
|
* Register an event listener.
|
|
* @param eventName Name of the event to listen for
|
|
* @param listenerFunc Callback function to invoke when the event occurs
|
|
* @returns A handle that can be used to remove the listener
|
|
*/
|
|
addListener(eventName: "nfcStatusChanged", listenerFunc: (status: NfcStatusChangedEvent) => void): Promise<PluginListenerHandle>;
|
|
addListener(eventName: "tagDetected", listenerFunc: (tag: TagDetectedEvent) => void): Promise<PluginListenerHandle>;
|
|
/**
|
|
* Remove all event listeners registered for this plugin.
|
|
*/
|
|
removeAllListeners(): Promise<void>;
|
|
/**
|
|
* Internal method to notify listeners of events
|
|
*/
|
|
private notifyListeners;
|
|
}
|