slot refused to allocate exclusive session for the card

Hi Guys I try to use smart card reader with my ipad project and after trying to make init session with the card got error from cryptotokenkit

Message from debug log : [smartcard] slot refused to allocate exclusive session for the card "Session error: Error Domain=CryptoTokenKit Code=-2 "(null)""

// connect to the card
        mngr?.getSlot(withName: slotName, reply: {
            (slot:TKSmartCardSlot?) in
            let card = slot?.makeSmartCard()
            if card != nil {
                
                // begin session
                card?.beginSession{
                   ( success:Bool,error:Error?) in
                    if success {
                        // Send 1st APDU
                        card?.send(ins: 0x84, p1: 0x00, p2: 0x00,le:8){
                            (data:Data?,sw:UInt16,error:Error?) in
                            if error != nil {
                                print("sendIns error:",error!)
                            }else{
                                print("Response:",data!,String(sw,radix: 16))
                                //String(format: "%02X", data! as CVarArg)
                            }
                        }
                        
                    }else{
                        print("Session error:",error!)
                    }
                }
            }else{
                print("No card found")
            }
        })

Error -2 is TKErrorCodeCommunicationError, which is pretty generic.

Does this happen consistently? Or is hard to reproduce?

Have you tried it on multiple different types of card? Or can you only test this with a specific card type?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

slot refused to allocate exclusive session for the card
 
 
Q