Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt 6.2.2. iOS & NFC Tag reading; What is possible and what is not?
Forum Updated to NodeBB v4.3 + New Features

Qt 6.2.2. iOS & NFC Tag reading; What is possible and what is not?

Scheduled Pinned Locked Moved Unsolved Qt 6
1 Posts 1 Posters 344 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Frime
    wrote on last edited by
    #1

    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.plist
    • CoreNFC.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!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved