I'm trying to read a tag generated by my app that emulates event input tags; in my NFC reader app and I get this error:
<NSXPCConnection: 0x300a108c0> connection to service with pid 62 named com.apple.nfcd.service.corenfc: Exception caught during decoding of received selector didDetectExternalReaderWithNotification:, dropping incoming message.
Exception: Exception while decoding argument 0 (#2 of invocation):
Exception: decodeObjectForKey: class "NFFieldNotificationECP1_0" not loaded or does not exist
(
0 CoreFoundation 0x0000000192b00f2c 76A3B198-3C09-323E-8359-0D4978E156F5 + 540460
1 libobjc.A.dylib 0x000000018a9a32b8 objc_exception_throw + 60
2 Foundation 0x0000000191932584 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 38276
3 Foundation 0x0000000191930d10 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 32016
4 Foundation 0x000000019198f460 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 418912
5 Foundation 0x000000019198c510 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 406800
6 Foundation 0x00000001919e4cf4 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 769268
7 Foundation 0x00000001919e3a60 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 764512
8 Foundation 0x00000001919e31c4 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 762308
9 Foundation 0x00000001919e307c D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 761980
10 libxpc.dylib 0x00000001ef5a1cbc CD0F76A8-713A-3FDB-877E-386B089BC2D1 + 72892
11 libxpc.dylib 0x00000001ef5a3908 CD0F76A8-713A-3FDB-877E-386B089BC2D1 + 80136
12 libdispatch.dylib 0x000000010401e87c _dispatch_client_callout4 + 20
13 libdispatch.dylib 0x000000010403bec4 _dispatch_mach_msg_invoke + 516
14 libdispatch.dylib 0x00000001040264a4 _dispatch_lane_serial_drain + 376
15 libdispatch.dylib 0x000000010403cea8 _dispatch_mach_invoke + 480
16 libdispatch.dylib 0x00000001040264a4 _dispatch_lane_serial_drain + 376
17 libdispatch.dylib 0x000000010402743c _dispatch_lane_invoke + 460
18 libdispatch.dylib 0x0000000104034404 _dispatch_root_queue_drain_deferred_wlh + 328
19 libdispatch.dylib 0x0000000104033a38 _dispatch_workloop_worker_thread + 444
20 libsystem_pthread.dylib 0x00000001ef550934 _pthread_wqthread + 288
21 libsystem_pthread.dylib 0x00000001ef54d0cc start_wqthread + 8
)
(
0 CoreFoundation 0x0000000192b00f2c 76A3B198-3C09-323E-8359-0D4978E156F5 + 540460
1 libobjc.A.dylib 0x000000018a9a32b8 objc_exception_throw + 60
2 Foundation 0x000000019198f680 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 419456
3 Foundation 0x000000019198c510 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 406800
4 Foundation 0x00000001919e4cf4 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 769268
5 Foundation 0x00000001919e3a60 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 764512
6 Foundation 0x00000001919e31c4 D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 762308
7 Foundation 0x00000001919e307c D27A6EC5-943C-3B0E-8D15-8840FD2914F0 + 761980
8 libxpc.dylib 0x00000001ef5a1cbc CD0F76A8-713A-3FDB-877E-386B089BC2D1 + 72892
9 libxpc.dylib 0x00000001ef5a3908 CD0F76A8-713A-3FDB-877E-386B089BC2D1 + 80136
10 libdispatch.dylib 0x000000010401e87c _dispatch_client_callout4 + 20
11 libdispatch.dylib 0x000000010403bec4 _dispatch_mach_msg_invoke + 516
12 libdispatch.dylib 0x00000001040264a4 _dispatch_lane_serial_drain + 376
13 libdispatch.dylib 0x000000010403cea8 _dispatch_mach_invoke + 480
14 libdispatch.dylib 0x00000001040264a4 _dispatch_lane_serial_drain + 376
15 libdispatch.dylib 0x000000010402743c _dispatch_lane_invoke + 460
16 libdispatch.dylib 0x0000000104034404 _dispatch_root_queue_drain_deferred_wlh + 328
17 libdispatch.dylib 0x0000000104033a38 _dispatch_workloop_worker_thread + 444
18 libsystem_pthread.dylib 0x00000001ef550934 _pthread_wqthread + 288
19 libsystem_pthread.dylib 0x00000001ef54d0cc start_wqthread + 8
)
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm developing a ticket app with Host card emulation. The session starts correctly the first time, but when trying to emulate a second ticket, after the first one has been read by the reader, or after the emulation has been canceled by the user, it doesn't work correctly for a while.
This is my CardSessionManager:
import CoreNFC
@available(iOS 17.4, *)
class CardSessionManager {
private static var cardSession: CardSession? = nil
private static var presentmentIntent: NFCPresentmentIntentAssertion? = nil
static func initCardSession(_ accessCode: String) {
cardSession?.invalidate()
cardSession = nil
let ProcessAPDU: (_: Data) -> Data = { capdu in
var response = Data(accessCode.utf8)
response.append(0x90)
response.append(0x00)
return response
}
Task {
guard NFCReaderSession.readingAvailable,
CardSession.isSupported,
await CardSession.isEligible else {
return
}
do {
presentmentIntent = try await NFCPresentmentIntentAssertion.acquire()
cardSession = try await CardSession()
} catch {
return
}
if let cardSession {
for try await event in cardSession.eventStream {
switch event {
case .sessionStarted:
cardSession.alertMessage = String(localized: "Searching reader...")
try await cardSession.startEmulation()
case .readerDetected:
cardSession.alertMessage = String(localized: "Reading...")
case .readerDeselected:
cardSession.alertMessage = String(localized: "Successful reading!")
await cardSession.stopEmulation(status: .success)
case .received(let cardAPDU):
cardSession.alertMessage = String(localized: "Communicating with reader.")
do {
try await cardAPDU.respond(response: ProcessAPDU(cardAPDU.payload))
} catch {
cardSession.alertMessage = error.localizedDescription
}
case .sessionInvalidated(reason: _):
cardSession.alertMessage = String(localized: "Ending communication with reader.")
presentmentIntent = nil
@unknown default:
break
}
}
}
}
}
}
Topic:
App & System Services
SubTopic:
Hardware