Federico Torres
10/18/2023, 4:56 PMNFCNDEFReaderSessionDelegateProtocol
from kotlin code. The problem is that this protocol was translated from OBJ-C to Kotlin like this:
public expect interface NFCNDEFReaderSessionDelegateProtocol : platform.darwin.NSObjectProtocol {
@kotlin.commonizer.ObjCCallable public open expect fun readerSession(session: platform.CoreNFC.NFCNDEFReaderSession, didDetectTags: kotlin.collections.List<*>): kotlin.Unit { /* compiled code */ }
@kotlin.commonizer.ObjCCallable public abstract expect fun readerSession(session: platform.CoreNFC.NFCNDEFReaderSession, didDetectNDEFs: kotlin.collections.List<*>): kotlin.Unit
@kotlin.commonizer.ObjCCallable public abstract expect fun readerSession(session: platform.CoreNFC.NFCNDEFReaderSession, didInvalidateWithError: platform.Foundation.NSError): kotlin.Unit
@kotlin.commonizer.ObjCCallable public open expect fun readerSessionDidBecomeActive(session: platform.CoreNFC.NFCNDEFReaderSession): kotlin.Unit { /* compiled code */ }
}
Meaning that there are two readerSession
methods with the exact same signature, thus I am unable to implement all the abstract methods of this interface from Kotlin codeAnton Saatze
10/19/2023, 9:37 AMCBCentralManagerDelegate
https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate?language=objc
The workaround I came up with: provide an Interface, that has all your callback Methods and some swiftcode has to implement the interface and calls them.
In your case:
NFCNDEFReaderSessionDelegateProtocolInterface {
// the two you need
fun readerSessionDidDetectTags(session: platform.CoreNFC.NFCNDEFReaderSession, didDetectTags: kotlin.collections.List<*>)
fun readerSessionDidDetectNDEFs(session: platform.CoreNFC.NFCNDEFReaderSession, didDetectTags: kotlin.collections.List<*>)
// for consistency
fun readerSessionDidInvalidateWithError(session: platform.CoreNFC.NFCNDEFReaderSession, didInvalidateWithError: platform.Foundation.NSError)
fun readerSessionDidBecomeActive(session: platform.CoreNFC.NFCNDEFReaderSession)
}
Let your Switftcode inherit these methods and call them when the swift func
gets called.
And eventually inject that class which implemented NFCNDEFReaderSessionDelegateProtocolInterface into your shared code.Federico Torres
10/19/2023, 2:59 PMAnton Saatze
11/06/2023, 6:23 AMAnton Saatze
05/15/2024, 3:19 PM