Download Winsoft NFC Library for iOS v4.4 Full Source for for Delphi 10.4 - 11

Winsoft NFC Library for iOS v4.4 Full Source for for Delphi 10.4 - 11

Winsoft NFC Library for iOS v4.4 Full Source for for Delphi 10.4 - 11
Winsoft NFC Library for iOS v4.4 Full Source for for Delphi 10.4 - 11


Delphi NFC library for iOS.

Uses Core NFC framework
Available for Delphi 10.4 - 11
Source code included in registered version
Royalty free distribution in applications

Installation

1. unpack infclib.zip file to some folder
2. copy all files from Delphi11 subfolder (when using Delphi 11) to Examples\Delphi subfolder
3. open Demo.dproj demo example located in subfolder Examples\Delphi and compile it


What's new

Version 4.4
added TNDefTag.Session property
added TFeliCaTag.Session property
added TISO15693Tag.Session property
added TISO7816Tag.SendCommandAPDU method
added TISO7816Tag.ProprietaryCoding property
added TISO7816Tag.Session property
added TMiFareTag.Session property
added TNfcTag.Session property
added TNDefSession.NestedCalls property
added Force parameter to TNDefSession.Invalidate procedure
added TNfcTagSession.NestedCalls property
added Force parameter to TNfcTagSession.Invalidate procedure
renamed CoreNFC unit to Winsoft.iOS.CoreNFC
renamed iNfcLib unit to Winsoft.iOS.Nfc
improved demo example


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 = record
    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 = record
    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; const Error: TNfcError);
  TReadCompletion = reference to procedure(const Message: TNDefMessage; const Error: TNfcError);
  TWriteCompletion = reference to procedure(const Error: TNfcError);

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

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

  TNDefTags = TArray<TNDefTag>;

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

  TConnectCompletion = reference to procedure(const Error: TNfcError);

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

    property AlertMessage: string read write;
    property IsReady: Boolean read;
    property NestedCalls: Integer read write;
    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 = record
    property FeliCaTag: TFeliCaTag read;
    property IsAvailable: Boolean read;
    property ISO15693Tag: TISO15693Tag read;
    property ISO7816Tag: TISO7816Tag read;
    property MiFareTag: TMiFareTag read;
    property Session: TNfcTagSession read;
    property Tag: NFCTag read;
    property TagType: TTagType read;
  end;

  TNfcTags = TArray<TNfcTag>;

  TGetInfoCompletion = reference to procedure(DsfId, Afi, BlockSize, BlockCount{, IcReference}: Integer{; const Error: TNfcError}); // Delphi seems to be supporting 4 completion parameters only
  TGetSecurityCompletion = reference to procedure(const Security: TArray<Byte>; const Error: TNfcError);
  TLockAfiCompletion = reference to procedure(const Error: TNfcError);
  TLockBlockCompletion = reference to procedure(const Error: TNfcError);
  TLockDsfiCompletion = reference to procedure(const Error: TNfcError);
  TReadBlockCompletion = reference to procedure(const Data: TBytes; const Error: TNfcError);
  TReadBlocksCompletion = reference to procedure(const Data: TArray<TBytes>; const Error: TNfcError);
  TReadBlocksFastCompletion = reference to procedure(const Data: TArray<TBytes>; const Error: TNfcError);
  TResetToReadyCompletion = reference to procedure(const Error: TNfcError);
  TSelectCompletion = reference to procedure(const Error: TNfcError);
  TStayQuietCompletion = reference to procedure(const Error: TNfcError);
  TWriteAfiCompletion = reference to procedure(const Error: TNfcError);
  TWriteBlockCompletion = reference to procedure(const Error: TNfcError);
  TWriteBlocksCompletion = reference to procedure(const Error: TNfcError);
  TWriteDsfiCompletion = reference to procedure(const Error: TNfcError);

  TISO15693Tag = record // NFC-V
    procedure GetInfo(Completion: TGetInfoCompletion);
    procedure GetSecurity(Block, Count: Byte; Completion: TGetSecurityCompletion);
    procedure LockAfi(Completion: TLockAfiCompletion);
    procedure LockBlock(Block: Byte; Completion: TLockBlockCompletion);
    procedure LockBlockEx(Block: Word; Completion: TLockBlockCompletion);
    procedure LockDsfi(Completion: TLockDsfiCompletion);
    procedure ReadBlock(Block: Byte; Completion: TReadBlockCompletion);
    procedure ReadBlockEx(Block: Word; Completion: TReadBlockCompletion);
    procedure ReadBlocks(Block, Count: Byte; Completion: TReadBlocksCompletion);
    procedure ReadBlocksEx(Block, Count: Word; Completion: TReadBlocksCompletion);
    procedure ReadBlocksFast(Block, Count: Byte; Completion: TReadBlocksFastCompletion);
    procedure ResetToReady(Completion: TResetToReadyCompletion);
    procedure Select(Completion: TSelectCompletion);
    procedure StayQuiet(Completion: TStayQuietCompletion);
    procedure WriteAfi(Afi: Byte; Completion: TWriteAfiCompletion);
    procedure WriteBlock(Block: Byte; const Data: TBytes; Completion: TWriteBlockCompletion);
    procedure WriteBlockEx(Block: Word; const Data: TBytes; Completion: TWriteBlockCompletion);
    procedure WriteBlocks(Block: Byte; const Data: TArray<TBytes>; Completion: TWriteBlocksCompletion);
    procedure WriteBlocksEx(Block: Word; const Data: TArray<TBytes>; Completion: TWriteBlocksCompletion);
    procedure WriteDsfi(Dsfi: Byte; Completion: TWriteDsfiCompletion);

    property Identifier: TBytes read;
    property Manufacturer: LongWord read;
    property RequestFlags: TRequestFlags read write;
    property SerialNumber: TBytes read;
    property Session: TNfcTagSession read;
    property Tag: NFCISO15693Tag read;
  end;

  TISO7816Tag = record
    property AID: string read;
    property ApplicationData: TBytes read;
    property HistoricalBytes: TBytes read;
    property Identifier: TBytes read;
    property ProprietaryCoding: Boolean read;
    property Session: TNfcTagSession read;
    property Tag: NFCISO7816Tag read;
  end;

  TFeliCaTag = record
    property Manufacturer: TBytes read;
    property Session: TNfcTagSession read;
    property SystemCode: TBytes read;
    property Tag: NFCFeliCaTag read;
  end;

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

  TAuthenticateCompletion = reference to procedure(PACK: Word; const ErrorMessage: string; const Error: TNfcError);
  TSendCommandCompletion = reference to procedure(const Response: TBytes; const Error: TNfcError);
  TWriteCommandCompletion = reference to procedure(const ErrorMessage: string; const Error: TNfcError);

  TMiFareTag = record
    procedure SendCommand(const Command: TBytes; Completion: TSendCommandCompletion);
    procedure GetVersion(Completion: TSendCommandCompletion);
    procedure Read(Page: Byte; Completion: TSendCommandCompletion);
    procedure FastRead(StartPage, EndPage: Byte; Completion: TSendCommandCompletion);
    procedure Write(Page: Byte; Data: Cardinal; Completion: TWriteCommandCompletion);
    procedure ReadCounter(Completion: TSendCommandCompletion);
    procedure ReadSignature(Completion: TSendCommandCompletion);
    procedure Authenticate(Password: Cardinal; Completion: TAuthenticateCompletion);

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

  TNfcTagDetectEvent = procedure(Sender: TObject; const 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 = ''; Force: Boolean = False);
    procedure Restart;
    procedure Scan;

    property AlertMessage: string read write;
    property IsReady: Boolean read;
    property NestedCalls: Integer read write;
    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;


Only for V.I.P
Warning! You are not allowed to view this text.
  • 22