Swiftpack.co - yanngodeau/SimplyNFC as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by yanngodeau.
yanngodeau/SimplyNFC 1.0.1
Simply read and write NFC tags with iPhone ๐Ÿ“ฒ
โญ๏ธ 22
๐Ÿ•“ 2 years ago
iOS
.package(url: "https://github.com/yanngodeau/SimplyNFC.git", from: "1.0.1")

SimplyNFC

Simply read and write NFC tags with iPhone (iOS 14.0+)

GitHub license Platform Swift

Installation

Swift package manager

Go to File | Swift Packages | Add Package Dependency... in Xcode and search for ยซย SimplyNFCย ยป

Cathage

You can use Carthage to install SimplyNFC by adding it to your Cartfile.

github "yanngodeau/SimplyNFC"

Manual

  1. Put SimplyNFC repo somewhere in your project directory.
  2. In Xcode, add SimplyNFC.xcodeproj to your project
  3. On your app's target, add the SimplyNFC framework:
    1. as an embedded binary on the General tab.
    2. as a target dependency on the Build Phases tab.

Usage

Read tag

Reading NCFNDEFMessage from tag

import SimplyNFC

let nfcManager = NFCManager()
nfcManager.read { manager in
    // Session did become active
    manager.setMessage("๐Ÿ‘€ Place iPhone near the tag to read")
} didDetect: { manager, result in
    switch result {
    case .failure:
        manager.setMessage("๐Ÿ‘Ž Failed to read tag")
    case .success:
        manager.setMessage("๐Ÿ™Œ Tag read successfully")
   }
}

Write on tag

Writing NFCNDEFMessage on tag

import SimplyNFC

let nfcManager = NFCManager()
nfcManager.write(message: ndefMessage) { manager in
    // Session did become active
    manager.setMessage("๐Ÿ‘€ Place iPhone near the tag to be written on")
} didDetect: { manager, result in
    switch result {
    case .failure:
        manager.setMessage("๐Ÿ‘Ž Failed to write tag")
    case .success:
        manager.setMessage("๐Ÿ™Œ Tag successfully written")
   }
}

Contribute

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

License

SimplyNFC is distributed under the MIT License.

Author

Based on code by @tattn

GitHub

link
Stars: 22
Last commit: 22 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics