Crash on CardSession

We are working on an HCE application following your documentation. Almost everything is working fine except that we encounter a crash when using CardSession.init() method.

We are calling CardSession.isEligible() before CardSession.init().

This crash is random and affects very few user and we did not find a way yet to reproduce this crash on our side.

Our theory is CardSession.isEligible() is doing thing under the hood and make CardSession.init() cause a crash, but that just our theory.

Here are some stacks :

CoreNFC/NFCCardSession.swift:431: Fatal error: Previous session exists
0   libswiftCore.dylib              0x000000019ed73800 _assertionFailure(_:_:file:line:flags:) + 168 (AssertCommon.swift:171)
1   CoreNFC                         0x000000025b99f630 NFCCardSession.startSession() + 296 (NFCCardSession.swift:431)
2   CoreNFC                         0x000000025b994771 CardSession.begin() + 1 (CardSession.swift:337)
3   CoreNFC                         0x000000025b99427d CardSession.init() + 1 (CardSession.swift:320)
4   Paiement Mobile                 0x000000010197f345 HceNativeSDK.startCardSession() + 1

Pretty sure CardSession.isEligible() is not doing anything to crash your app.

You will get this crashing error when you already have an active NFC session in your app. I would suggest to check that your code checks for previous sessions that may have not been closed, or perhaps a lingering variable holding the previous session that hasn't been released yet, etc.

In other words, this is a bug in your code you need to resolve. Not an issue caused by CardSession.isEligible()

Crash on CardSession
 
 
Q