I am using Core NFC and I established the connection with the card, (it means that the info.plist is correct and the entitlement should be correct as well). The app detects the card, but after sending the command 'tag.sendCommand()' I receive the following message:
[CoreNFC] -[NFCTagReaderSession transceive:tagUpdate:error:]:879 Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement}
So, what is missing or what am I doing wrong?
Here is the code:
nfcSession = NFCTagReaderSession(pollingOption: .iso14443, delegate: self)
nfcSession?.begin()
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
guard !tags.isEmpty else { return }
let hexString = //...
if case let .iso7816(tag) = tags[0] {
session.connect(to: tags[0]) { error in
if let error = error {
print("Error: \(error.localizedDescription)")
return
}
let apdu = hexString.convertToAPDU()
tag.sendCommand(apdu: apdu) { (response: Data, sw1: UInt8, sw2: UInt8, error: Error?) in
print([UInt8](response))
// here is when the error appears, in the completion
}
}
}
}
Don't know what to do in this situation, and can't find much information about this specific problem, tried everything. Created new bundle id and provisioning profile, reviewed the info.plist and entitlements...
Here is my entitlements file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
<string>TAG</string>
</array>
</dict>
</plist>
And in the info.plist I have this:
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>315449432E494341</string>
</array>
<key>NFCReaderUsageDescription</key>
<string>NFC reason</string>