# NFCReaderWriter
**Repository Path**: kais_coder/NFCReaderWriter
## Basic Information
- **Project Name**: NFCReaderWriter
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-02-21
- **Last Updated**: 2025-02-21
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# NFCReaderWriter
[](https://cocoapods.org/pods/NFCReaderWriter)
[](https://github.com/Carthage/Carthage)
[](https://github.com/janlionly/NFCReaderWriter/blob/master/LICENSE)
[](https://github.com/janlionly/NFCReaderWriter)

## Description
**NFCReaderWriter** which supports to read data from NFC chips(iOS 11), write data to NFC chips(iOS 13) and read NFC tags infos(iOS 13) by iOS devices. Compatible with both Swift and Objective-C.
## Installation
### CocoaPods
```swift
pod 'NFCReaderWriter'
```
### Carthage
```swift
github "janlionly/NFCReaderWriter"
```
### Swift Package Manager
- iOS: Open Xcode, File->Swift Packages, search input **https://github.com/janlionly/NFCReaderWriter.git**, and then select Version Up to Next Major **1.1.4** < .
- Or add dependencies in your `Package.swift`:
```swift
.package(url: "https://github.com/janlionly/NFCReaderWriter.git", .upToNextMajor(from: "1.1.4")),
```
## Usage
1. Set your provisioning profile to support for **Near Field Communication Tag Reading**;
2. Open your project target, on **Signing & Capabilities** tab, add the Capability of **Near Field Communication Tag Reading**;
3. Remember to add **NFCReaderUsageDescription** key for descriptions to your Info.plist.
4. Support for read tag identifier(iOS 13), you should add your NFC tag type descriptions to your Info.plist.
(eg: like **com.apple.developer.nfc.readersession.felica.systemcodes**, **com.apple.developer.nfc.readersession.iso7816.select-identifiers**)
**More information please run demo above.**
```swift
/// ----------------------
/// 1. NFC Reader(iOS 11):
/// ----------------------
// every time read NFC chip's data, open a new session to detect
readerWriter.newReaderSession(with: self, invalidateAfterFirstRead: true, alertMessage: "Nearby NFC Card for read")
readerWriter.begin()
// implement NFCReaderDelegate to read NFC chip's data
func reader(_ session: NFCReader, didDetectNDEFs messages: [NFCNDEFMessage]) {
for message in messages {
for (i, record) in message.records.enumerated() {
print("Record \(i+1): \(String(data: record.payload, encoding: .ascii))")
// other record properties: typeNameFormat, type, identifier
}
}
readerWriter.end()
}
/// ----------------------
/// 2. NFC Writer(iOS 13):
/// ----------------------
// every time write data to NFC chip, open a new session to write
readerWriter.newWriterSession(with: self, isLegacy: true, invalidateAfterFirstRead: true, alertMessage: "Nearby NFC Card for write")
readerWriter.begin()
// implement NFCReaderDelegate to write data to NFC chip
func reader(_ session: NFCReader, didDetect tags: [NFCNDEFTag]) {
// here for write test data
var payloadData = Data([0x02])
let urls = ["apple.com", "google.com", "facebook.com"]
payloadData.append(urls[Int.random(in: 0..
Contact with me by email: janlionly@gmail.com
## Contribute
I would love you to contribute to **NFCReaderWriter**
## License
**NFCReaderWriter** is available under the MIT license. See the [LICENSE](https://github.com/janlionly/NFCReaderWriter/blob/master/LICENSE) file for more info.