NFC card reader is an advanced tracking system enabled in iOS where it can be integrated with various application developed by iOS App Development Company India. NFC is tagging system where each item is tagged with read and writes options. NFC tagging is used for payment, baggage tracking, door system handling, ID card scanning etc. where customers/users are facing lot of problem, standing in long queue and get more security during outgoing/incoming from door system.
NFC is associated with various things like message payload, tag, name and reader which can be displayed during popup of message in the app. NFC can be used from iPhone 7 onward because this particular facility will not be capable of scanning and capturing the data in older iPhone. NFC provides great user experience and security to most of provider.
1) The developer need to enable the near field communication in core capability in XCode
2) Developer need to import the CoreNFC library from apple default library
3) Developer need to add settings in the plist file and it will provide permission to app to access NFC facility in the device
NFCReaderUsageDescription
YOUR_PRIVACY_DESCRIPTION
4) Developer need to add capability and key inside entitlement also so that it can be access in device for particular app
com.developer.nfc.reader.formats
NFC
5) Developer need to enabled NFC feature in the apple development center where provisioning profile is enabled with NFC card tagging
6) Developer needs to write logic to create the session and message in the app. Then developer need to start session to create the session for app communication.
privatevarnfcCardSessionCreate: NFCNDEFReaderSession! privatevarnfcCardMessageCreate: [[NFCNDEFMessage]] = []
7) Developer need to create Session for app communication and popping the message in the app as well as the session need to begin.
self. nfcCardSessionCreate = NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: false)
self. nfcCardSessionCreate.alertMessage = “Scan your NFC tag With iPhone” self. nfcCardSessionCreate.begin()
8) Developer has to listen the NFC tagging facility so developer need to implement session and confirm the payload which message need to show on popup after scanning.
extensionNFCTableViewController : NFCNDEFReaderSessionDelegate {
funcreaderSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
print(“Error reading NFC: (error.localizedDescription)”)
}
funcreaderSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
print(“New NFC Tag detected:”)
for message in messages {
for record in message.records {
print(“Format nameType: (record.typeNameFormat)”)
print(“Format PayloadType: (record.payload)”)
print(“Format RecordType: (record.type)”)
print(“Format IdentifierType: (record.identifier)”)
}
}
self.nfcCardMessageCreate.append(messages)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
9) Developer need to create the controller to populate data in the cell and message need to be displayed in proper manner. Once it scanned the tag then particular data will be populating in the cell.
extensionNFCTableViewController {
overridefuncnumberOfSections(in tableView: UITableView) -> Int {
return self. nfcCardMessageCreate.count
}
overridefunctableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self. nfcCardMessageCreate [section].count
}
overridefunctableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
letnumberOfMessages = self. nfcCardMessageCreate [section].count
letheaderScanTitle= numberOfMessages == 1 ? “One Message” : “(numberOfMessages) Messages”
returnheaderScanTitle
}
overridefunctableView(_ tableView: UITableView, cellForRowAtindexPath: IndexPath) ->UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: “NFCTableCell”, for: indexPath) as! NFCTableViewCell
letnfcTag = self. nfcCardMessageCreate [indexPath.section][indexPath.row]
cell.textLabel?.text = “(nfcTag.records.count) Records”
return cell
}
}