Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/developeracademy-postech/2024-nc2-m1-nfc
https://github.com/developeracademy-postech/2024-nc2-m1-nfc
Last synced: about 10 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/developeracademy-postech/2024-nc2-m1-nfc
- Owner: DeveloperAcademy-POSTECH
- Created: 2024-06-17T03:21:24.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-29T03:26:34.000Z (4 months ago)
- Last Synced: 2024-07-29T04:33:32.865Z (4 months ago)
- Language: Swift
- Size: 7.11 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ๐ฅ Youtube Link
(์ถํ ๋ง๋ค์ด์ง ์ ํ๋ธ ๋งํฌ ์ถ๊ฐ)## ๐ก About Augmented Reality
๐ก **NFC๋?**
NFC๋ near field communication์ ์ค์๋ง๋ก, ๊ทผ๊ฑฐ๋ฆฌ ํต์ ๊ธฐ์ ์ ๋งํจ.
Nfc ๊ธฐ์ ์ ์ด์ฉํ์ฌ 10cm์ด๋ด์ ๋งค์ฐ ๊ฐ๊น์ด ๊ฑฐ๋ฆฌ์์ ๋ฐ์ดํฐ๋ฅผ ๊ตํํ ์ ์์ต๋๋ค.
**โ NFC ํ์ฉ ๋ฐฉ๋ฒ**
1๏ธโฃย ๋ฐ์ดํฐ ๊ตํ
- NameDrop๊ณผ Airdrop ๊ฐ์ด nfc๋ฅผ ์ด์ฉํด ๋ฐ์ดํฐ๋ฅผ ๊ตํํ ์ ์์ต๋๋ค. (airdrop์ wifi ์ด์ฉํ๋ ๊ฑด๋ฐ, iOS17 ์ด์๋ถํฐ airdrop์ nfc๋ก๋ ์ด์ฉ๊ฐ๋ฅํ๋ค๊ณ ํฉ๋๋ค.)
2๏ธโฃย ๊ฒฐ์ ์์คํ
- Apple Pay์ ํฐ๋จธ๋ ๊ตํต์นด๋ ์คํฐ์ปค
3๏ธโฃย ๋จ์ถ์ด / ์ ๋ณด ํ์ธ
- ์์ดํฐ ๋จ์ถ์ด์ NFC ์คํฐ์ปค๋ฅผ ์ฐ๊ฒฐํ์ฌ ํ๊น ํ์ ๋ ์ํ๋ ํ๋์ ํ๊ฒ ํ ์ ์์ต๋๋ค.
- ๋ฆฌ๋๊ธฐ์ ํธ๋ํฐ์ ํ๊น ํด ๋ค์ํ ์ ๋ณด๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.## ๐ฏ What we focus on?
๐ช Tag reader์ ์์ดํฐ์ ์ง์ค
- ๋ค์ํ ํ์ฉ ๋ฐฉ๋ฒ ์ค ํ๋์จ์ด์ ์ฑ์ ์ฐ๋์ ํด๋ณด๊ณ ์ถ์ด์ ๋ฆฌ๋๊ธฐ์ ํธ๋ํฐ์ ํ๊น ํ์ ๋ ์ ๋ณด๊ฐ ๋จ๋ ๊ฒ์ ์ง์คํ์์ต๋๋ค.
## ๐ผ Use Case
๐ **NFC ํ๊ทธ๋ฅผ ํ์ฉํ์ฌ ๋ฏธํ ๋ฃธ์ ์์ฝํ ์ ์๊ฒ ๋ง๋ค์!**
- who : ๋ฏธํ ๋ฃธ์ ์ฌ์ฉํ๋ ค๋ ์์นด๋ฐ๋ฏธ์&์๋์ด ๋ฌ๋
- when: ๋ฏธํ ๋ฃธ ์์ฝ์ด ํ์ํ ๋
- how: nfc ํ๊ทธ๋ฅผ ํ์ฉํ์ฌ ๊ฐ ๋ฏธํ ๋ฃธ ์์ฝ ํ์ด์ง๋ฅผ ํตํด ๋น์ผ์์ฝํจ.## ๐ผ๏ธ Prototype
### 1. ํ๊น- ์ฑ์ ๋ค์ด๊ฐ์ โ์ค์บํ๊ธฐโ ๋ฒํผ์ ๋๋ฅด๊ณ ๊ฐ ๋ฏธํ ๋ฃธ ์์ ๋ถ์ด์๋ NFC ์คํฐ์ปค์ ํธ๋ํฐ์ ๊ฐ๊น์ด ๊ฐ์ ธ๊ฐ๋๋ค.
![2 %20%E1%84%89%E1%85%B3%E1%84%8F%E1%85%A2%E1%86%AB%20%E1%84%87%E1%85%B2](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/d9ee362c-2c54-4d7c-99a6-5b4b34a87ab0)
![2 %20%E1%84%89%E1%85%B3%E1%84%8F%E1%85%A2%E1%86%AB%20%E1%84%87%E1%85%B2-1](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/6e95d6e7-b767-4fae-ad01-5fd07ab830a1)### 2. ๋ฉ์ธํ์ด์ง
- ์ฑ๊ณต์ ์ผ๋ก ์ค์บ์ด ๋๋ฉด ๋ฉ์ธํ์ด์ง์ ํด๋น ๋ฏธํ ๋ฃธ์ ๋ํ ์์ฝํ์ด์ง๊ฐ ๋น๋๋ค.
- ์์ฝํ๊ณ ์ถ์ ์๊ฐ๋ ์ ํํฉ๋๋ค.
![2 %20%E1%84%91%E1%85%AD(%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%A9%E1%86%AFx)-1](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/4e92de3f-7077-44ad-b7c9-816619984f14)
![2 %20%E1%84%91%E1%85%AD(%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%A9%E1%86%AFx)-2](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/6b206dfc-222d-492e-bd8f-f2ccf776194a)### 3. ์์ฝํ๊ธฐ
- ์์ฝํ๊ธฐ๋ฅผ ๋๋ฅด๋ฉด ์์ฝ์ฐฝ์ด ๋น๋๋ค. ์ ๋ณด๋ฅผ ์ ๋ ฅํฉ๋๋ค.
![iPhone%2014%20%26%2015%20Pro%20-%20%E1%84%8B%E1%85%A8%E1%84%8B%E1%85%A3%E1%86%A8%E1%84%92%E1%85%AA%E1%84%86%E1%85%A7%E1%86%AB](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/052dc221-6232-410a-9e85-1c53c216cc40)
![iPhone%2014%20%26%2015%20Pro%20-%20%E1%84%8B%E1%85%A8%E1%84%8B%E1%85%A3%E1%86%A8%E1%84%92%E1%85%AA%E1%84%86%E1%85%A7%E1%86%AB_%20%E1%84%8B%E1%85%A8%E1%84%8B%E1%85%A3%E1%86%A8%20%E1%84%8B%E1%85%B5%E1%86%AB%E1%84%8B%E1%85%AF%E1%86%AB-1](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/4079e435-13ea-43ce-a16f-332e91cab22f)### 4. ์์ / ์ญ์ ํ๊ธฐ
![2 %20%E1%84%91%E1%85%AD(%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%A9%E1%86%AFx)](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/29085645-e39e-4ec6-9cda-864bd2601f74)
![iPhone%2014%20%26%2015%20Pro%20-%20%E1%84%89%E1%85%AE%E1%84%8C%E1%85%A5%E1%86%BC%E1%84%92%E1%85%AA%E1%84%86%E1%85%A7%E1%86%AB](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/34a9307d-3eac-48bc-9497-706d592fbdf8)![iPhone%2014%20%26%2015%20Pro%20-%20%E1%84%8B%E1%85%A8%E1%84%8B%E1%85%A3%E1%86%A8%E1%84%92%E1%85%AA%E1%84%86%E1%85%A7%E1%86%AB_%20%E1%84%8B%E1%85%A8%E1%84%8B%E1%85%A3%E1%86%A8%20%E1%84%8B%E1%85%B5%E1%86%AB%E1%84%8B%E1%85%AF%E1%86%AB](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/f5c80f1d-bfca-428b-acfd-bae7bd01436b)
![2 %20%E1%84%91%E1%85%AD(%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%A9%E1%86%AFx)-3](https://github.com/DeveloperAcademy-POSTECH/2024-NC2-M1-NFC/assets/160375101/94290cc0-bcef-4bcb-a751-b2f6955f8d17)##
## ๐ ๏ธ About Code
**NFC ํ๊ทธ ์ฝ๊ธฐ ๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ํด ํ์ํ ํต์ฌ ๊ธฐ๋ฅ ์๊ฐํ ํ ์๋ฃ์ ๋๋ค.**
``` swift
private func startNFCTagging() {
let session = NFCTagReaderSession(pollingOption: .iso14443, delegate: NFCFeature.shared)
session?.begin()
}class NFCFeature: NSObject, NFCTagReaderSessionDelegate {
static let shared = NFCFeature()var completeNavigate: (() -> Void)?
func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("become active")
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: any Error) {
if let readerError = error as? NFCReaderError, readerError.code != .readerSessionInvalidationErrorFirstNDEFTagRead {
print("NFC Reader session ์ค๋ฅ \(error.localizedDescription)")
}
}
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
print(tags)
if let completeNavigate {
completeNavigate()
}
session.invalidate()
}
}
```**์ ๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ํด ์์ฑ๋ NFC ๊ธฐ์ ์ ํต์ฌ ๊ธฐ๋ฅ์ ๊ตฌํํ ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.**
NFC ํ๊ทธ๋ฅผ ๊ฐ์งํ๊ณ , ๊ฐ์ง๋ ํ๊ทธ๊ฐ ์์ ๋ ํน์ ์์ ์ ์ํํฉ๋๋ค. ํ๊ทธ๋ฅผ ์ฝ๋ ๊ฒ์ ๋ชฉํ๋กํ๋ ๋ณธ ์ฝ๋๋ ํฌ๊ฒ NFC ํ๊ทธ์ ๊ฐ์ง๋ฅผ ์์ํ๋ ๋จ๊ณ์ NFC ํ๊ทธ๋ฅผ ๊ฐ์งํ๋ ๋จ๊ณ๋ก ๋ถ๋ฆฌํ ์ ์์ต๋๋ค.
``` swift
private func startNFCTagging() {
let session = NFCTagReaderSession(pollingOption: .iso14443, delegate: NFCFeature.shared)
session?.begin()
}
```**NFC ํ๊ทธ์ ๊ฐ์ง๋ฅผ ์์ํ๋ ๋ฉ์๋์ ์ฝ๋๋ ํ์ํ ๋ถ๋ถ์ ๋๋ค.**
NFCTagReaderSession์ด๋ CoreNFC ํ๋ ์์ํฌ์ ํด๋์ค ์ค ํ๋๋ก, ๋ค์ํ NFC ํ๊ทธ๋ฅผ ๊ฒ์ํ๊ณ ์ํธ์์ฉ ํ ์ ์๊ฒ ํด์ค๋๋ค.
``` swift
class NFCFeature: NSObject, NFCTagReaderSessionDelegate {
static let shared = NFCFeature()var completeNavigate: (() -> Void)?
func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("become active")
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: any Error) {
if let readerError = error as? NFCReaderError, readerError.code != .readerSessionInvalidationErrorFirstNDEFTagRead {
print("NFC Reader session ์ค๋ฅ \(error.localizedDescription)")
}
}
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
print(tags)
if let completeNavigate {
completeNavigate()
}
session.invalidate()
}
}
```**NFC ํ๊ทธ๋ฅผ ๊ฐ์งํ๋ ๋จ๊ณ๋, ํ์ํ ์ฝ๋์ ๊ฐ์ด ํํํ์์ต๋๋ค.**
NFCFeature class๋ NFCTagReaderSessiondelegate protocol์ ์ฑํํ์ฌ NFC ํ๊ทธ ๊ฐ์ง์ ๊ด๋ จ๋ ์ด๋ฒคํธ๋ฅผ ์ฒ๋ฆฌํฉ๋๋ค.
``` swift
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: any Error) {
if let readerError = error as? NFCReaderError, readerError.code != .readerSessionInvalidationErrorFirstNDEFTagRead {
print("NFC Reader session ์ค๋ฅ \(error.localizedDescription)")
}
}
```**NFC ํ๊ทธ๋ฅผ ๊ฐ์ง ํ๋ ๋์ ์๊ธฐ๋ ์ค๋ฅ๋ฅผ ์ฒ๋ฆฌํ๋ ๋ฉ์๋๋ฅผ ๊ตฌํํ์์ต๋๋ค.**
์ด ๋ฉ์๋๋ NFC ๋ฆฌ๋ ์ธ์ ์ด ์ค๋ฅ๋ก ์ธํด ๋ฌดํจํ๋์์ ๋ ํธ์ถ๋ฉ๋๋ค.
``` swift
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
print(tags)
if let completeNavigate {
completeNavigate()
}
session.invalidate()
}
```**NFC ํ๊ทธ ๊ฐ์ง ํ ์ด๋ฒคํธ๋ฅผ ์์ฑํ๊ธฐ ์ํ ์ฝ๋์ ๋๋ค.**
์ด ๋ฉ์๋๋ ํ๋ ์ด์์ NFC ํ๊ทธ๊ฐ ๊ฐ์ง ๋์์ ๋ ํธ์ถ๋๊ณ , ๊ฐ์ง๋ ํ๊ทธ์ ๋ชฉ๋ก์ ์ถ๋ ฅํฉ๋๋ค. ๋ง์ฝ ํด๋ก์ ๊ฐ ์ค์ ๋์ด ์์ผ๋ฉด ์ด๋ฅผ ํธ์ถํ๊ณ ์ดํ ์ธ์ ์ ๋ฌดํจํํฉ๋๋ค.