在iOS13 Beta版中。当我尝试使用NFCISO15693Tag API
customCommandWithRequestFlag:customCommandCode:customRequestParameters:completionHandler:
发送customCommand代码到标记,
我得到了错误:
-[NFCTagReaderSession transceive:tagUpdate:error:]:706 Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement}
我尝试过:
1,重新配置NFC的隐私。
2,将配置添加到我的info.plist
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
<string>12FC</string>
</array>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>D2760000850101</string>
</array>
但是,他们都不适合我。
以下是我的源代码:
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if let st = tags.first {
session.connect(to: st) { (error) in
if error != nil {
session.invalidate(errorMessage: "Connection error. Please try again.")
return
}
if case let .iso15693(type5Tag) = st {
print(type5Tag.identifier.toString())
print(type5Tag.icSerialNumber.toString())
print(type5Tag.isAvailable)
type5Tag.select(requestFlags: [.address, .highDataRate]) { (selectError) in
print("selectError")
print(selectError)
}
type5Tag.customCommand(requestFlags: [.highDataRate, .address], customCommandCode: 0xB4, customRequestParameters: Data([0x02])) { (data, error) in
print("custom command: get random number")
print(data.toString())
print(error)
}
}
}
}
实际上,出现以下错误:
-[NFCTagReaderSession transceive:tagUpdate:error:]:706 Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement}
期望4个字节的随机数。