4. List connected card readers
Once the PluginApi
instance has been retrieved and initialized, you will be able to list the connected card readers.
There are two ways to do this:
- You can either list all card readers and find the one you need:
'use strict'
// simply list all card readers. Array will be empty if there are not card readers.
pluginApi.getCardReader()
.then((connectedReaders: CardReader[]) => {
})
- Or you can let the Wrapper filter out card readers that contain a specific card:
'use strict'
import { BeID, BeLawyer } from 'connective-wrapper';
// list all card readers that contain a BeID card. Array will be empty if there are no readers containing a BeID card.
pluginApi.getCardReader(BeID.cardInfo)
.then((connectedReaders: CardReader[]) => {
});
// OR list all card readers that contain a BeLawyer card. Array will be empty if there are no readers containing a BeLawyer card.
pluginApi.getCardReader(BeLawyer.cardInfo)
.then((connectedReaders: CardReader[]) => {
});
// and so on...
Note that all card readers can tell you if they have a card inserted or not: If they have a card inserted, they will provide a CardInfo
object containing an atr
and description
value with which the inserted card can be identified.
The Wrapper currently comes with 2 built-in supported cards, BeID and BeLawyer. Both provide a CardInfo
object which can be used to detect the respective card type.