IDTech iOS/OSX SDK Guide  1.1.084
API reference for UniPay 1.5
Sample Project Tutorial

Using Xcode 6.4, we will create a sample project that will interface with the UniPay 1.5 and will perform the following activities:

  • Auto-Connect and display connection status
  • Get Device Firmware
  • Start/Stop Transaction Request for MSR
  • Start/Complete/Cancel EMV Transaction
  • Show LCD Display for EMV transaction
  • Automatically select first AID or first Language if prompted

Protocol Delegates:

  • Delegate to receive card swipes
  • Delegate to detect headphone plug changes
  • Delegate to detect device connected
  • Delegate to detect device disconnected
  • Delegate to receive EMV tag data

Step 1: Create New Project

Create a new Single View Application in Xcode

new_project1.png
new_project2.png

Step 2: Import Frameworks

Import the necessary framework/libraries

Step 3: Design Interface

Design the User Interface by editing the iPhone storyboard file
Open your storyboard and add items to so it contains the following buttons/fields:

  • Add a label to the top that will signify connection/disconnection status.
  • Add text views to communicate data from the UniPay 1.5 and for EMV LCD display information. Remove the Editable behavior if you don't want the keyboard to pop up if you accidentally select it.
  • Add buttons to execute the following functions:
    • Get Firmware
    • Start MSR
    • Start ICC EMV
    • Complete ICC EMV
    • Cancel Transaction (add constraints accordingly so layout maps to intended screen size)
XIB2.png

Step 4: Configure Header File

In the header file, perform the following:

  • Add Import statements to utilize frameworks
  • Amend the view controller interface
  • Create an IBOutlet for the two UITextView and link it as a Referencing Outlet to the UITextView on the storyboard
  • Create an IBOutlet for the UILabel and link it as a Referencing Outlet to the UILabel on the storyboard
  • Create the 4 IBAction for the buttons, and link them to the "Touch Up Inside" event on the storyboard buttons
#import <UIKit/UIKit.h>
#import <IDTech/IDTech.h>
@interface ViewController : UIViewController<IDT_UniPayI_V_Delegate>
{
IBOutlet UITextView *lcdTextView;
IBOutlet UITextView *logTextView;
IBOutlet UILabel *connectedLabel;
}
-(IBAction) getFirmware:(id)sender;
-(IBAction) startMSR_CTLS:(id)sender;
-(IBAction) startEMV:(id)sender;
-(IBAction) completeEMV:(id)sender;
-(IBAction) cancelTransaction:(id)sender;
@property(nonatomic, strong) UITextView *lcdTextView;
@property(nonatomic, strong) UITextView *logTextView;
@property(nonatomic, strong) UILabel *connectedLabel;
@end

Storyboard Source Code

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="UniPay 1.5 Disconnected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eDI-cL-7k6">
<rect key="frame" x="16" y="20" width="568" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BNt-fB-6Ni">
<rect key="frame" x="288" y="53" width="24" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8zA-5c-Igm">
<rect key="frame" x="16" y="49" width="264" height="30"/>
<animations/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Get Firmware">
<color key="titleColor" red="0.068003949080000001" green="0.072250786509999998" blue="0.44422978940000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="getFirmware:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="ONf-1N-HDd"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QvK-Hw-R0Z">
<rect key="frame" x="320" y="49" width="264" height="30"/>
<animations/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Start MSR">
<color key="titleColor" red="0.068003949080000001" green="0.072250786509999998" blue="0.44422978940000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="startMSR_CTLS:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="T65-oV-nQ4"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c2A-gb-32n">
<rect key="frame" x="288" y="91" width="24" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KML-Tf-QdE">
<rect key="frame" x="16" y="87" width="264" height="30"/>
<animations/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Start ICC EMV">
<color key="titleColor" red="0.068003949080000001" green="0.072250786509999998" blue="0.44422978940000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="startEMV:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="jXs-Hw-Y20"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="U0Y-vt-9An">
<rect key="frame" x="16" y="125" width="568" height="30"/>
<animations/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="Cancel Transaction">
<color key="titleColor" red="0.068003949080000001" green="0.072250786509999998" blue="0.44422978940000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="cancelTransaction:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="rOr-8n-gJz"/>
</connections>
</button>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" editable="NO" text="LCD DISPLAY INFO" textAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="XfN-t5-Cxv">
<rect key="frame" x="16" y="188" width="568" height="128"/>
<animations/>
<color key="backgroundColor" red="0.98823529480000005" green="0.89411765340000005" blue="0.8156862855" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="20"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" editable="NO" text="LOG INFO" translatesAutoresizingMaskIntoConstraints="NO" id="Ybs-ph-PwR">
<rect key="frame" x="16" y="356" width="568" height="229"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="EMV LCD DISPLAY" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oIl-91-J9y">
<rect key="frame" x="16" y="168" width="568" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="LOG" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ngg-AN-FNd">
<rect key="frame" x="16" y="335" width="568" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IhF-UM-clE">
<rect key="frame" x="320" y="87" width="264" height="30"/>
<animations/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title="Complete ICC EMV">
<color key="titleColor" red="0.068003949080000001" green="0.072250786509999998" blue="0.44422978940000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="completeEMV:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="sBg-6w-7jS"/>
</connections>
</button>
</subviews>
<animations/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<constraints>
<constraint firstItem="ngg-AN-FNd" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="07N-fx-7L7"/>
<constraint firstItem="Ybs-ph-PwR" firstAttribute="top" secondItem="ngg-AN-FNd" secondAttribute="bottom" id="0R5-b0-UV6"/>
<constraint firstItem="IhF-UM-clE" firstAttribute="top" secondItem="QvK-Hw-R0Z" secondAttribute="bottom" constant="8" id="3wT-WY-O6y"/>
<constraint firstItem="KML-Tf-QdE" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="4xE-db-nPj"/>
<constraint firstItem="XfN-t5-Cxv" firstAttribute="top" secondItem="U0Y-vt-9An" secondAttribute="bottom" constant="33" id="7QY-kl-X8y"/>
<constraint firstItem="eDI-cL-7k6" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="7fb-Cp-cCv"/>
<constraint firstItem="KML-Tf-QdE" firstAttribute="top" secondItem="8zA-5c-Igm" secondAttribute="bottom" constant="8" id="8tx-HW-5Nd"/>
<constraint firstItem="oIl-91-J9y" firstAttribute="top" secondItem="U0Y-vt-9An" secondAttribute="bottom" constant="13" id="9kb-SL-MjC"/>
<constraint firstItem="8zA-5c-Igm" firstAttribute="top" secondItem="eDI-cL-7k6" secondAttribute="bottom" constant="8" id="9p8-gV-NRe"/>
<constraint firstItem="QvK-Hw-R0Z" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="AJW-HY-0Gz"/>
<constraint firstItem="oIl-91-J9y" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="Azf-64-uHX"/>
<constraint firstAttribute="centerX" secondItem="c2A-gb-32n" secondAttribute="centerX" id="CIj-z7-20O"/>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="Ybs-ph-PwR" secondAttribute="bottom" constant="15" id="Hr6-bD-4h3"/>
<constraint firstItem="ngg-AN-FNd" firstAttribute="top" secondItem="XfN-t5-Cxv" secondAttribute="bottom" constant="19" id="Hvp-Bq-Jmg"/>
<constraint firstItem="8zA-5c-Igm" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="KNU-4P-TIA"/>
<constraint firstItem="eDI-cL-7k6" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" id="NTQ-83-15F"/>
<constraint firstItem="IhF-UM-clE" firstAttribute="leading" secondItem="c2A-gb-32n" secondAttribute="trailing" constant="8" id="P4V-QW-bw0"/>
<constraint firstAttribute="centerX" secondItem="BNt-fB-6Ni" secondAttribute="centerX" id="RYY-mX-lui"/>
<constraint firstItem="Ybs-ph-PwR" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="W3k-et-sOA"/>
<constraint firstItem="c2A-gb-32n" firstAttribute="leading" secondItem="KML-Tf-QdE" secondAttribute="trailing" constant="8" id="WHf-cP-6l6"/>
<constraint firstItem="eDI-cL-7k6" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="WeO-Q4-l8C"/>
<constraint firstItem="U0Y-vt-9An" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="egE-ht-XL2"/>
<constraint firstItem="XfN-t5-Cxv" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="eoS-jT-tfR"/>
<constraint firstItem="Ybs-ph-PwR" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="gxc-v5-oE5"/>
<constraint firstItem="QvK-Hw-R0Z" firstAttribute="leading" secondItem="BNt-fB-6Ni" secondAttribute="trailing" constant="8" id="jaT-3B-urM"/>
<constraint firstItem="U0Y-vt-9An" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="l4a-eF-pGd"/>
<constraint firstItem="QvK-Hw-R0Z" firstAttribute="top" secondItem="eDI-cL-7k6" secondAttribute="bottom" constant="8" id="pAi-z4-TRm"/>
<constraint firstItem="XfN-t5-Cxv" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="pBl-HM-a2m"/>
<constraint firstItem="ngg-AN-FNd" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="qLF-YA-Iay"/>
<constraint firstItem="oIl-91-J9y" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="s28-T7-lrr"/>
<constraint firstItem="U0Y-vt-9An" firstAttribute="top" secondItem="IhF-UM-clE" secondAttribute="bottom" constant="8" id="wOn-ol-vv0"/>
<constraint firstItem="IhF-UM-clE" firstAttribute="trailing" secondItem="kh9-bI-dsS" secondAttribute="trailingMargin" id="wn6-dg-B6v"/>
<constraint firstItem="BNt-fB-6Ni" firstAttribute="leading" secondItem="8zA-5c-Igm" secondAttribute="trailing" constant="8" id="xXS-U6-Voz"/>
</constraints>
</view>
<connections>
<outlet property="connectedLabel" destination="eDI-cL-7k6" id="EYe-RB-KZq"/>
<outlet property="lcdTextView" destination="XfN-t5-Cxv" id="aN5-cG-h6Y"/>
<outlet property="logTextView" destination="Ybs-ph-PwR" id="EOn-F5-kzy"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

Step 5: Configure Method File

In the header file, perform the following:

  • set delegate and initialize IDT_UniPayI_V singleton object in the viewDidLoad method. Reference: Call the Singleton instance of the IDT_UniPayI_V framework object
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [[IDT_UniPayI_V sharedController] setDelegate:self];
    }
  • Implement protocol delegate IDT_UniPayI_VDelegate::deviceDisconnected() and IDT_UniPayI_VDelegate::deviceConnected() to monitor connect/disconnect events and modify our connection label upon change. Reference: Implement optional delegate protocols
    -(void) deviceConnected{
    [connectedLabel setText:@"UNIPAY 1.5 CONNECTED"];
    }
    -(void) deviceDisconnected{
    [connectedLabel setText:@"UNIPAY 1.5 DISCONNECTED"];
    }
  • Implement protocol delegate swipeMSRData:() to receive card swipe data. Reference: Implement optional delegate protocols
    -(void) appendMessageToResults:(NSString*) message{
    [logTextView setText:[NSString stringWithFormat:@"%@\n====================\n%@",message, self.logTextView.text]];
    }
    - (void) swipeMSRData:(IDTMSRData*)cardData{
    NSLog(@"--MSR event Received, Type: %d, data: %@", cardData.event, cardData.encTrack1);
    switch (cardData.event) {
    case EVENT_MSR_CARD_DATA:
    {
    switch (cardData.captureEncodeType) {
    case CAPTURE_ENCODE_TYPE_ISOABA:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encode Type: %@", @"ISO/ABA"]];
    break;
    case CAPTURE_ENCODE_TYPE_AAMVA:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encode Type: %@", @"AA/MVA"]];
    break;
    case CAPTURE_ENCODE_TYPE_Other:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encode Type: %@", @"Other"]];
    break;
    case CAPTURE_ENCODE_TYPE_Raw:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encode Type: %@", @"Raw"]];
    break;
    case CAPTURE_ENCODE_TYPE_JIS_I:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encode Type: %@", @"CAPTURE_ENCODE_TYPE_JIS_I"]];
    break;
    case CAPTURE_ENCODE_TYPE_JIS_II:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encode Type: %@", @"CAPTURE_ENCODE_TYPE_JIS_II"]];
    break;
    default:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encode Type: %@", @"UNKNOWN"]];
    break;
    }
    switch (cardData.captureEncryptType) {
    case CAPTURE_ENCRYPT_TYPE_AES:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encrypt Type: %@", @"AES"]];
    break;
    case CAPTURE_ENCRYPT_TYPE_TDES:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encrypt Type: %@", @"TDES"]];
    break;
    case CAPTURE_ENCRYPT_TYPE_NO_ENCRYPTION:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encrypt Type: %@", @"NONE"]];
    break;
    default:
    [self appendMessageToResults:[NSString stringWithFormat:@"Encrypt Type: %@", @"UNKNOWN"]];
    break;
    }
    [self appendMessageToResults:[NSString stringWithFormat:@"Full card data: %@", cardData.cardData]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Track 1: %@", cardData.track1]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Track 2: %@", cardData.track2]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Track 3: %@", cardData.track3]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Length Track 1: %i", cardData.track1Length]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Length Track 2: %i", cardData.track2Length]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Length Track 3: %i", cardData.track3Length]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Encoded Track 1: %@", cardData.encTrack1.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Encoded Track 2: %@", cardData.encTrack2.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Encoded Track 3: %@", cardData.encTrack3.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Hash Track 1: %@", cardData.hashTrack1.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Hash Track 2: %@", cardData.hashTrack2.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"Hash Track 3: %@", cardData.hashTrack3.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"KSN: %@", cardData.KSN.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"\nSessionID: %@", cardData.sessionID.description]];
    [self appendMessageToResults:[NSString stringWithFormat:@"\nReader Serial Number: %@", cardData.RSN]];
    [self appendMessageToResults:[NSString stringWithFormat:@"\nRead Status: %2X", cardData.readStatus]];
    if (cardData.unencryptedTags != nil) [self appendMessageToResults:[NSString stringWithFormat:@"Unencrytped Tags: %@", cardData.unencryptedTags.description]];
    if (cardData.encryptedTags != nil) [self appendMessageToResults:[NSString stringWithFormat:@"Encrypted Tags: %@", cardData.encryptedTags.description]];
    if (cardData.maskedTags != nil) [self appendMessageToResults:[NSString stringWithFormat:@"Masked Tags: %@", cardData.maskedTags.description]];
    NSLog(@"Track 1: %@", cardData.track1);
    NSLog(@"Track 2: %@", cardData.track2);
    NSLog(@"Track 3: %@", cardData.track3);
    NSLog(@"Encoded Track 1: %@", cardData.encTrack1.description);
    NSLog(@"Encoded Track 2: %@", cardData.encTrack2.description);
    NSLog(@"Encoded Track 3: %@", cardData.encTrack3.description);
    NSLog(@"Hash Track 1: %@", cardData.hashTrack1.description);
    NSLog(@"Hash Track 2: %@", cardData.hashTrack2.description);
    NSLog(@"Hash Track 3: %@", cardData.hashTrack3.description);
    NSLog(@"SessionID: %@", cardData.sessionID.description);
    NSLog(@"nReader Serial Number: %@", cardData.RSN);
    NSLog(@"Read Status: %2X", cardData.readStatus);
    NSLog(@"KSN: %@", cardData.KSN.description);
    return;
    }
    break;
    case EVENT_MSR_CANCEL_KEY:
    {
    [self appendMessageToResults:[NSString stringWithFormat:@"(Event) MSR Cancel Key received: %@", cardData.encTrack1]];
    return;
    }
    break;
    case EVENT_MSR_BACKSPACE_KEY:
    {
    [self appendMessageToResults:[NSString stringWithFormat:@"(Event) MSR Backspace Key received: %@", cardData.encTrack1]];
    return;
    }
    break;
    case EVENT_MSR_ENTER_KEY:
    {
    [self appendMessageToResults:[NSString stringWithFormat:@"(Event) MSR Enter Key received: %@", cardData.encTrack1]];
    return;
    }
    break;
    case EVENT_MSR_UNKNOWN:
    {
    [self appendMessageToResults:[NSString stringWithFormat:@"(Event) MSR unknown event, data: %@", cardData.encTrack1]];
    return;
    }
    break;
    default:
    break;
    }
    }
  • Implement protocol delegate plugStatusChange:() to automatically attempt connection attempt.
    - (void) plugStatusChange:(BOOL)deviceInserted{
    if (deviceInserted) {
    [self appendMessageToResults: @"device Attached. Attempting connection"];
    [[IDT_UniPayI_V sharedController] device_connectToAudioReader];
    }
    else{
    [self appendMessageToResults: @"device removed."];
    }
    }
  • Implement protocol delegate emvTransactionData:() to report EMV transaction results
    - (void) emvTransactionData:(IDTEMVData*)emvData errorCode:(int)error{
    NSLog(@"EMV_RESULT_CODE_V2_response = %2X",error);
    [self appendMessageToResults:[NSString stringWithFormat:@"EMV_RESULT_CODE_V2_response = %2X",error]];
    if (emvData == nil) {
    [self appendMessageToResults:[NSString stringWithFormat:@"EMV TRANSACTION ERROR. Refer to EMV_RESULT_CODE_V2_response = 0x%2X",error]];
    return;
    }
    if (emvData.resultCodeV2 == EMV_RESULT_CODE_V2_GO_ONLINE) {
    [self appendMessageToResults:@"ONLINE REQUEST"];
    }
    if (emvData.resultCodeV2 == EMV_RESULT_CODE_V2_APPROVED || emvData.resultCodeV2 == EMV_RESULT_CODE_V2_APPROVED_OFFLINE ) {
    [self appendMessageToResults:@"APPROVED"];
    }
    if (emvData.resultCodeV2 == EMV_RESULT_CODE_V2_MSR_SUCCESS) {
    [self appendMessageToResults:@"MSR Data Captured"];
    }
    if (emvData.cardType == 0) {
    [self appendMessageToResults:@"CONTACT"];
    }
    if (emvData.cardType == 1) {
    [self appendMessageToResults:@"CONTACTLESS"];
    }
    if (emvData.unencryptedTags != nil) [self appendMessageToResults:[NSString stringWithFormat:@"Unencrytped Tags: %@", emvData.unencryptedTags.description]];
    if (emvData.encryptedTags != nil) [self appendMessageToResults:[NSString stringWithFormat:@"Encrypted Tags: %@", emvData.encryptedTags.description]];
    if (emvData.maskedTags != nil) [self appendMessageToResults:[NSString stringWithFormat:@"Masked Tags: %@", emvData.maskedTags.description]];
    }
  • Implement protocol delegate lcdDisplay:() to receive LCD messages, and automatically select 1st menu item/language when presented with choices. Normal operation would require a choice be made by card holder.
    - (void) lcdDisplay:(int)mode lines:(NSArray*)lines{
    NSMutableString* str = [NSMutableString new];
    if (lines != nil) {
    for (NSString* s in lines) {
    [str appendString:s];
    [str appendString:@"\n"];
    }
    }
    switch (mode) {
    case 0x10:
    //clear screen
    lcdTextView.text = @"";
    break;
    case 0x03:
    lcdTextView.text = str;
    break;
    case 0x01:
    case 0x02:
    case 0x08:{
    [[IDT_UniPayI_V sharedController] emv_callbackResponseLCD:mode selection:(unsigned char)1];;
    }
    break;
    default:
    break;
    }
    }
  • Implement the button press methods
    -(IBAction) getFirmware:(id)sender{
    NSString *result;
    logTextView.text = @"";
    RETURN_CODE rt = [[IDT_UniPayI_V sharedController] device_getFirmwareVersion:&result];
    if (RETURN_CODE_DO_SUCCESS == rt)
    {
    [self appendMessageToResults: [NSString stringWithFormat:@"Get FM info: %@", result]];
    }
    }
    -(IBAction) startMSR_CTLS:(id)sender{
    logTextView.text = @"";
    RETURN_CODE rt = [[IDT_UniPayI_V sharedController] msr_startMSRSwipe];
    if(RETURN_CODE_DO_SUCCESS == rt){
    [self appendMessageToResults:@"EnableMSR: OK."];
    }
    }
    -(IBAction) startEMV:(id)sender{
    logTextView.text = @"";
    RETURN_CODE rt = [[IDT_UniPayI_V sharedController] emv_startTransaction:1.00 amtOther:0 type:0 timeout:60 tags:nil forceOnline:false fallback:true];
    if (RETURN_CODE_DO_SUCCESS == rt)
    {
    [self appendMessageToResults: @"Start Transaction Command Accepted"];
    }
    }
    -(IBAction) completeEMV:(id)sender{
    logTextView.text = @"";
    RETURN_CODE rt = [[IDT_UniPayI_V sharedController] emv_completeOnlineEMVTransaction:true hostResponseTags:[IDTUtility hexToData:@"8A023030"] ];
    if (RETURN_CODE_DO_SUCCESS == rt)
    {
    [self appendMessageToResults: @"Complete Transaction Command Accepted"];
    }
    }
    -(IBAction) cancelTransaction:(id)sender{
    logTextView.text = @"";
    RETURN_CODE rt = [[IDT_UniPayI_V sharedController] msr_cancelMSRSwipe];
    if(RETURN_CODE_DO_SUCCESS == rt){
    [self appendMessageToResults:@"CancelMSR: OK."];
    }
    }