SCM iOS API
SCMEnvironment Class Reference

Main class for the Smart Card Middleware API. More...

Inherits NSObject.

Instance Methods

(NSArray *) - getBluetoothPeripherals
 
(void) - setConfigBluetooth:
 
(void) - scanPeripheral
 
(void) - stopScan
 
(void) - notifyApplicationDidEnterBackground
 
(void) - notifyApplicationWillTerminate
 
(NSArray *) - getReaders
 
(Reader *) - getReader:
 
(void) - addReaderEventListener:
 
(void) - removeReaderEventListener:
 
(NSString *) - getBluetoothPeriphUuidRegistered
 
(void) - initTagReaderSession:completionHandler:
 
(void) - endTagReaderSession:
 
(void) - updateTagReaderSessionMessage:
 
(BOOL) - isSupportedNfcTagReaderSession
 

Class Methods

(void) + createEnvironment:completionHandler:
 

Detailed Description

Main class for the Smart Card Middleware API.

This class provides the initial entry points from connecting to the iOS API, obtaining the readers and listening to events.

Method Documentation

◆ addReaderEventListener:()

- (void) addReaderEventListener: (id <ReaderEvents>)  listener

Registers a reader event listener.

Parameters
listenerthe listener object whose methods will be called when an event occurs.

◆ createEnvironment:completionHandler:()

+ (void) createEnvironment: (BOOL)  bluetoothSupport
completionHandler: (void(^)(SCMEnvironment *env, NSError *error))  completionHandler 

Initializing the list af all smart card readers attached to the device (SCMEnvironment#getReaders), and starts monitoring smart card reader events.

Note that if the device supports NFC Tag Reading, a Nfc Reader named NFC Interface will be added to (SCMEnvironment#getReaders) array.

Note that the SCMEnvironment must be created from your:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Parameters
bluetoothSupporttrue if the application wants to support bluetooth readers; false otherwise. Entitlements must be set accordingly.
completionHandlerthe completion handler block to be called as soon as the environment is created. The completion handler is executed on the main queue and takes the following parameters :
  • env the SCMEnvironment object.
  • error nil if the environment creation is completed successfully; otherwise an NSError encapsulates the reason of failure.

◆ endTagReaderSession:()

- (void) endTagReaderSession: (NSString *)  message

Closes the NFC Tag reader session and displays a feedback to the user. if the session was not successful, a message must be provided, which will be displayed to the user as an error. If the operation was successful, the message must be set to nil and a positive check mark will be displaye to the user.

Parameters
messagenil if the session was successful, or a message error if the session was not successful.

◆ getBluetoothPeripherals()

- (NSArray *) getBluetoothPeripherals

Gets an array of the bluetooth peripherals visible to the phone.

Returns
array of BluetoothPeripheral object.

◆ getBluetoothPeriphUuidRegistered()

- (NSString *) getBluetoothPeriphUuidRegistered

Gets the uuid of the registered bluetooth peripheral.

Returns
the uuid of the registered bluetooth peripheral, or nil if there is not a bluetooth peripheral registered.

◆ getReader:()

- (Reader *) getReader: (NSString *)  readerName

Gets the Reader object with the given name.

Parameters
readerNamethe reader name, as a NSString.
Returns
the Reader object.

◆ getReaders()

- (NSArray *) getReaders

Returns the list of all smart card readers attached to the phone.

Returns
the Reader list.

◆ initTagReaderSession:completionHandler:()

- (void) initTagReaderSession: (NSString *)  message
completionHandler: (void(^)(NSError *error))  completionHandler 

Start scanning for NFC tags. After calling this function, iOS will display an alert action sheet waiting to detect tags.

Parameters
messagedescriptive text message that is displayed on the alert action sheet once tag scanning has started. The string can be update dynamically by calling (SCMEnvironment#updateTagReaderSessionMessage:).
completionHandlerthe completion handler to be called if the alert action sheet has been canceled by the user or if there was a session timeout. If the operation has been ended explicitly by a (SCMEnvironment#endTagReaderSession:) call, the callback is not called.

◆ isSupportedNfcTagReaderSession()

- (BOOL) isSupportedNfcTagReaderSession

Returns YES if the device supports NFC Tag Reading.

Returns
YES if the device supports NFC Tag Reader Session; NO otherwise.

◆ notifyApplicationDidEnterBackground()

- (void) notifyApplicationDidEnterBackground

Call this from your:

-(void)applicationDidEnterBackground:(UIApplication *)application

◆ notifyApplicationWillTerminate()

- (void) notifyApplicationWillTerminate

Call this from your:

-(void)applicationWillTerminate:(UIApplication *)application

◆ removeReaderEventListener:()

- (void) removeReaderEventListener: (id <ReaderEvents>)  listener

Removes a reader event listener.

Parameters
listenerthe listener object to remove.

◆ scanPeripheral()

- (void) scanPeripheral

Scan for bluetooth peripherals.

◆ setConfigBluetooth:()

- (void) setConfigBluetooth: (NSString *)  uuid

Registers a bluetooth peripheral.

Parameters
uuidthe Universally Unique Identifier of the bluetooth peripheral.

◆ stopScan()

- (void) stopScan

Stop scan for bluetooth perihperals.

◆ updateTagReaderSessionMessage:()

- (void) updateTagReaderSessionMessage: (NSString *)  message

Update the text message that was displayed on the alert action sheet of the NFC Tag Reader Session.

Parameters
messagethe new text message to be displayed on the alert action sheet.

The documentation for this class was generated from the following files: