Skip to content

Instantly share code, notes, and snippets.

@jensmeder
Created June 6, 2017 20:22
Show Gist options
  • Save jensmeder/477cc2dfabf6aef486bbcd93d50aebb6 to your computer and use it in GitHub Desktop.
Save jensmeder/477cc2dfabf6aef486bbcd93d50aebb6 to your computer and use it in GitHub Desktop.
import UIKit
import CoreNFC
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, NFCNDEFReaderSessionDelegate {
var window: UIWindow?
var session: NFCNDEFReaderSession?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.session = NFCNDEFReaderSession(delegate: self, queue: DispatchQueue.global(qos: .background), invalidateAfterFirstRead: false)
self.session?.begin()
return true
}
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
print(error)
}
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
print(messages)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment