yshrkt / nfcsupport Goto Github PK
View Code? Open in Web Editor NEWSupport library for NFC NDEF Records
License: MIT License
Support library for NFC NDEF Records
License: MIT License
I'm developing an application in which I want to get the NFC serial number and Identifier of a NFC tag. When I press a button, I want the application to find the UID and serial number of the NFC card. The only problem is that I have no idea how to get the UID and and serial number if that's possible on iOS. I m trying to get NFC identifier but i don't know how to get serial number of NFC Tag.
Code:-
class ScanNFCTag: NFCTagReaderSessionDelegate {
import CoreNFC
var session: NFCTagReaderSession?
func scanNFCTag(sender: UIButton!) {
self.session = NFCTagReaderSession(pollingOption: .iso14443, delegate: self)
self.session?.alertMessage = "Hold Your Phone Near the NFC Tag"
self.session?.begin()
}
func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("Session Begin!")
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
print(error.localizedDescription)
}
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if tags.count > 1{
session.alertMessage = "More Than One Tag Detected, Please try again"
session.invalidate()
}
let tag = tags.first!
session.connect(to: tag) { (error) in
if nil != error{
session.invalidate(errorMessage: error?.localizedDescription ?? "")
}
if case let .miFare(sTag) = tag{
let UID = sTag.identifier.map{ String(format:"%.2hhx", $0)}.joined()
session.alertMessage = "Successfully linked tag to location"
session.invalidate()
DispatchQueue.main.async {
print("NFC Identifer = ", "\(UID)")
}
}
}
}
}
So, Here is the my code please let me know if i m doing wrong please correct me. Can someone please explain to me how to get serial number and UID of NFC tag,
Any help would be greatly appreciated.
Thanks in advance.
Hello @yshrkt !
I just wanted to alert you to a parsing issue with your Package.swift
fine in your default branch in the Swift Package Index. Your package is currently showing a 404 there because of it.
The issue is that your Package.swift
file is inconsistent:
// swift-tools-version:4.2
…
swiftLanguageVersions: [.v5_2]
}
This leads to:
❯ swift package dump-package
/Users/sas/Downloads/NFCSupport: error: manifest parse error(s):
/Users/sas/Downloads/NFCSupport/Package.swift:23:30: error: type 'SwiftVersion' has no member 'v5_2'; did you mean 'v4_2'?
swiftLanguageVersions: [.v5_2]
^~~~
v4_2
PackageDescription.SwiftVersion:4:10: note: 'v4_2' declared here
case v4_2
^
Fatal error: Index out of range
fish: 'swift package dump-package' terminated by signal SIGILL (Illegal instruction)
Simply changing v5_2
to v4_2
on your default branch should fix it. We re-scan packages automatically and your package should com back online by itself then :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.