I'm trying to hack NFC support into my app, but CoreNFC is not yet supported by Qt.
https://bugreports.qt.io/browse/QTBUG-63253 It seems simple enough though, but I an not good with Objective-C, and all the examples are in Swift. So here's what I tried: 0. Take care of entitlements and such. 1. For my QIOSApplication Deleage, it was @interface QIOSApplicationDelegate : UIResponder <UIApplicationDelegate> changed to: @interface QIOSApplicationDelegate : UIResponder <UIApplicationDelegate, NFCNDEFReaderSessionDelegate> 2. Add @property (strong, nonatomic) NFCNDEFReaderSession *nfcSession; to the delegate 3. Just as a test, in didFinishLaunchingWithOptions, add: if (![NFCNDEFReaderSession readingAvailable]) { qDebug() << "NFC not available"; } else { qDebug() << "NFC available"; _nfcSession = [[NFCNDEFReaderSession alloc] initWithDelegate:self queue:nil invalidateAfterFirstRead:NO]; [_nfcSession beginSession]; } 4. Add the following functions to the app delegate: - (void)readerSession:(NFCNDEFReaderSession *)session didDetectNDEFs:( NSArray<NFCNDEFMessage *> *)messages { qDebug() << "NFCNDEFReaderSession didDetectNDEFs" << messages; NSLog(@"NFCNDEFReaderSession didDetectNDEFs: %@",messages); for (NFCNDEFMessage *message in messages) { qDebug() << message; for (NFCNDEFPayload *payload in message.records) { qDebug() << payload; } } } - (void)readerSession:(NFCNDEFReaderSession *)session didInvalidateWithError:( NSError *)error { NSLog(@"Something went wrong: %@",error); } 5. Launch App, present tag to phone (along the top) 6. On removal of the tag I get (3 attempts): 2018-10-04 17:36:09.291926-0400 testnfc[532:51484] [CoreNFC] 00000002 838b2f80 -[NFCNDEFReaderSession _connectTag:error:]:418 Error Domain=NFCError Code=100 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error, NSUnderlyingError=0x2818a2970 {Error Domain=nfcd Code=15 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error}}} 2018-10-04 17:36:13.579116-0400 testnfc[532:51484] [CoreNFC] 00000002 838b2f80 -[NFCNDEFReaderSession _connectTag:error:]:418 Error Domain=NFCError Code=100 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error, NSUnderlyingError=0x2818a03c0 {Error Domain=nfcd Code=15 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error}}} 2018-10-04 17:36:16.845026-0400 testnfc[532:51377] [CoreNFC] 00000002 838b2f80 -[NFCNDEFReaderSession _connectTag:error:]:418 Error Domain=NFCError Code=100 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error, NSUnderlyingError=0x2818a8bd0 {Error Domain=nfcd Code=15 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error}}} 7. The tag is valid because another app in the app store was able to get data from it. I'm really bad with Objective-C, so aside from compile errors, I don't know if what I am doing is right. I'm very unsure about that , NFCNDEFReaderSessionDelegate> part. Many thanks in advance. _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
