Last active
December 27, 2018 14:25
-
-
Save myrickchow32/d3d62f514388404d34656066db746eef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // invalidateAfterFirstRead = false | |
| var nfcSession = NFCNDEFReaderSession.init(delegate: self, queue: nil, invalidateAfterFirstRead: false) | |
| nfcSession.begin() | |
| extension ViewController: NFCNDEFReaderSessionDelegate { | |
| func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) { | |
| // Handling of [NFCNDEFMessage] and return the result String | |
| var result = ... | |
| // Step 8: didDetectNDEFs callback is run in background thread. All UI updates must be handled carefully. | |
| DispatchQueue.main.async { [weak self] in | |
| self?.nfcSession.invalidate() | |
| self?.showAlert("Scanned NFC tag info: " + result) // Simply show an UIAlertController with message | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment