Qt 6.2.2. iOS & NFC Tag reading; What is possible and what is not?
Unsolved
Qt 6
-
Hi Community,
I was so happy to learn that Qt NFC now talks to the iOS CoreNFC framework. However, I can't get my code, which works great on Android, to work on iOS.
Actually, I just want to read the UID of a Mifare Ultralight tag. The call to startTargetDetection returns only with the option QNearFieldTarget::TagTypeSpecificAccesss true. A small popup opens, but unfortunately my tag is not detected. Other NFC apps on iOS can read my tags without any problems.
My XCode settings:
Near Field Communication Tag Reading capability
added with the corresponding entries in the entitlements file.Privacy - NFC Scan Usage Description
added to Info.plistCoreNFC.framework
dependency added
My code:
NFCReader::NFCReader(QObject *parent) : QObject(parent), _manager(new QNearFieldManager(this)) { connect(_manager, SIGNAL(targetDetected(QNearFieldTarget*)), this, SLOT(targetDetected(QNearFieldTarget*))); connect(_manager, SIGNAL(targetLost(QNearFieldTarget*)), this, SLOT(targetLost(QNearFieldTarget*))); connect(_manager, &QNearFieldManager::adapterStateChanged, this, &NFCReader::handleAdapterStateChange); } void NFCReader::startRead() { qDebug()<< Q_FUNC_INFO; // returns true: qDebug()<<_manager->startTargetDetection(QNearFieldTarget::TagTypeSpecificAccesss); } bool NFCReader::ready() { qDebug()<< Q_FUNC_INFO; //false: qDebug()<<"A"<<_manager->isSupported(QNearFieldTarget::UnknownAccess); // true qDebug()<<"B"<<_manager->isSupported(QNearFieldTarget::AnyAccess); // unfortunately false, I expected true here: qDebug()<<"C"<<_manager->isSupported(QNearFieldTarget::NdefAccess); // false qDebug()<<"D"<<_manager->isSupported(QNearFieldTarget::TagTypeSpecificAccess); return _manager->isEnabled(); // is true } void NFCReader::targetDetected(QNearFieldTarget *target) { qDebug()<< Q_FUNC_INFO; QString uid = target->uid().toHex().toUpper(); qDebug()<< uid; Q_EMIT uidRead(uid); } void NFCReader::targetLost(QNearFieldTarget *target) { qDebug()<< Q_FUNC_INFO; target->deleteLater(); } void NFCReader::handleAdapterStateChange(QNearFieldManager::AdapterState state) { qDebug()<< Q_FUNC_INFO; if (state == QNearFieldManager::AdapterState::Online) { qDebug()<<"ONLINE"; } else if (state == QNearFieldManager::AdapterState::Offline) { qDebug()<<"OFFLINE"; } }
What am I missing?
thanks in advance!