NFC Library for iOS

NFC Library for iOS demo example
Delphi and C++ Builder NFC library for iOS.
  • uses Core NFC API
  • available for Delphi/C++ Builder XE8 - 10.3
  • source code included in registered version
  • royalty free distribution in applications

Library API

type
  ENfcError = class(Exception);

  TNfcError = record
    constructor Create(Error: NSError);

    property Code: LongInt read;
    property Description: string read;
    property Domain: string read;
    property Error: NSError read;
    property FailureReason: string read;
    property IsError: Boolean read;
    property RecoverySuggestion: string read;
  end;

  TNDefFormat = (Empty, WellKnown, Media, AbsoluteUri, External, Unknown, Unchanged);

  TNDefPayload = class
    constructor Create(Format: TNDefFormat; &Type, Identifier, Data: TBytes);

    property Data: TBytes read write;
    property Format: TNDefFormat read write;
    property Identifier: TBytes read write;
    property Payload: NFCNDEFPayload read;
    property &Type: TBytes read write;
  end;

  TNDefPayloads = TArray<TNDefPayload>;

  TNDefMessage = class
    constructor Create(const Payloads: TNDefPayloads);
    constructor Create(const Payloads: array of TNDefPayload);

    property Message: NFCNDEFMessage read;
    property PayloadCount: Integer read;
    property Payloads[Index: Integer]: TNDefPayload read;
  end;

  TNDefMessages = TArray<TNDefMessage>;

  TNDefStatus = (Unknown, NotSupported, ReadWrite, ReadOnly);

  TQueryStatusCompletion = reference to procedure(Status: TNDefStatus; Capacity: LongWord; Error: TNfcError);
  TReadCompletion = reference to procedure(const Message: TNDefMessage; Error: TNfcError);
  TWriteCompletion = reference to procedure(Error: TNfcError);

  TNDefTag = class
    procedure QueryStatus(Completion: TQueryStatusCompletion);
    procedure Read(Completion: TReadCompletion);
    procedure Write(const Message: TNDefMessage; Completion: TWriteCompletion);

    property IsAvailable: Boolean read;
    property Tag: NFCNDEFTag read;
  end;

  TNDefTags = TArray<TNDefTag>;

  TNfcErrorEvent = procedure(Sender: TObject; Error: TNfcError) of object;
  TNDefDetectEvent = procedure(Sender: TObject; Tags: TNDefTags) of object;

  TConnectCompletion = reference to procedure(Error: TNfcError);

  TNDefSession = class
    constructor Create(InvalidateAfterRead: Boolean = False);
    procedure Connect(Tag: TNDefTag; Completed: TConnectCompletion);
    procedure Invalidate(const ErrorMessage: string = '');
    procedure Restart;
    procedure Scan;

    property AlertMessage: string read write;
    property IsReady: Boolean read;
    property Session: NFCNDEFReaderSession read;

    property OnActive: TNotifyEvent read write;
    property OnDetect: TNDefDetectEvent read write;
    property OnError: TNfcErrorEvent read write;

    class property ReadingAvailable: Boolean read;
  end;

  TTagType = (Unknown, ISO15693, FeliCa, ISO7816Compatible, MiFare);

  TNfcTag = class
    property FeliCaTag: TFeliCaTag read;
    property IsAvailable: Boolean read;
    property ISO15693Tag: TISO15693Tag read;
    property ISO7816Tag: TISO7816Tag read;
    property MiFareTag: TMiFareTag read;
    property Tag: NFCTag read;
    property TagType: TTagType read;
  end;

  TNfcTags = TArray<TNfcTag>;

  TISO15693Tag = class
    property Identifier: TBytes read;
    property Manufacturer: LongWord read;
    property SerialNumber: TBytes read;
    property Tag: NFCISO15693Tag read;
  end;

  TISO7816Tag = class
    property AID: string read;
    property ApplicationData: TBytes read;
    property HistoricalBytes: TBytes read;
    property Identifier: TBytes read;
    property Tag: NFCISO7816Tag read;
  end;

  TFeliCaTag = class
    property Manufacturer: TBytes read;
    property SystemCode: TBytes read;
    property Tag: NFCFeliCaTag read;
  end;

  TMiFareFamily = (Unknown, Ultralight, Plus, DESFire);

  TSendCommandCompletion = reference to procedure(Response: TBytes; Error: TNfcError);

  TMiFareTag = class
    procedure SendCommand(Command: TBytes; Completion: TSendCommandCompletion);

    property Family: TMiFareFamily read;
    property HistoricalBytes: TBytes read;
    property Identifier: TBytes read;
    property Tag: NFCMiFareTag read;
  end;

  TNfcTagDetectEvent = procedure(Sender: TObject; Tags: TNfcTags) of object;

  TNfcTagSession = class
    constructor Create(Polling: TPolling = [TPollingType.ISO14443, TPollingType.ISO15693]);
    procedure Connect(Tag: TNfcTag; Completed: TConnectCompletion);
    procedure Invalidate(const ErrorMessage: string = '');
    procedure Restart;
    procedure Scan;

    property AlertMessage: string read write;
    property IsReady: Boolean read;
    property Session: NFCTagReaderSession read;
    property OnActive: TNotifyEvent read write;
    property OnDetect: TNfcTagDetectEvent read write;
    property OnError: TNfcErrorEvent read write;

    class property ReadingAvailable: Boolean read;
  end;

function BytesToHex(const Bytes: TBytes; Separator: Char = ':'): string;
function BytesToHex(const Bytes: TBytes; From, Count: Integer; Separator: Char = ':'): string;
								

Download and order

Order NFC Library $140,- USD (license for one developer)
Order NFC Library multi-license $420,- USD (license for all developers in company)
Order NFC Library year upgrades $70,- USD (registered users only)
Order NFC Library year upgrades multi-license $210,- USD (registered multilicense users only)

Related links