Reader
public final class Reader
Class that represent a smart card reader (either a physical, hardware reader, or a virtual smart card reader).
-
Returns the related
SCMEnvironmentof this reader.Note:
The reference to the
SCMEnvironmentfrom the reader isweakbecause environment keeps reference to the readers too.Declaration
Swift
public func getEnv() -> SCMEnvironment?Return Value
the related environment of this reader.
-
Returns the name of the reader.
Declaration
Swift
public func getName() -> StringReturn Value
The name of the reader.
-
Returns if the card is inserted in the reader.
Declaration
Swift
public func isCardPresent() -> BoolReturn Value
trueif the card is inserted in the reader,falseotherwise. -
Returns the type of the reader.
Declaration
Swift
public func getType() -> StringReturn Value
A string representing the type of the reader. It can be one of the following:
"usb""usbc""bluetooth""nfc"
-
Returns the type of the reader.
See also
ReaderTypeDeclaration
Swift
public func getType() -> ReaderTypeReturn Value
the type of the reader.
-
Gets the status of the reader.
See also
ReaderStatusDeclaration
Swift
public func getStatus() -> ReaderStatusReturn Value
the status of the reader.
-
Connects to the card inserted in the reader. This method succeeds only if the card is supported by the middleware.
Example:
func onReaderStateChanged(reader: Reader) { if (reader.isCardPresent() && reader.getStatus() == .OK) { reader.connect() { token, error in if let error = error { print("fail to connect to token: " + error.localizedDescription) } else { // do stuff with your token } } } }Declaration
Swift
public func connect(completionHandler: @escaping (_ token: Token?, _ error: NSError?) -> Void)Parameters
completionHandlerThe completion handler to call when the connection is complete. It takes the following parameters:
- token
Token?: the token object connected to the reader. - error
NSError?:nilif the operation is completed successfully; otherwise an error encapsulates the reason of failure.
Note
The completion handler is executed on the same type ofDispatchQueueas in the calling code. - token