Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Core NFC の新機能 / What's new in Core NFC (WWDC20)
Search
treastrain / Tanaka Ryoga
July 09, 2020
Programming
2
720
Core NFC の新機能 / What's new in Core NFC (WWDC20)
集まれSwift好き!Swift愛好会スピンオフ WWDC20セッション要約会 @ Online で発表した LT「Core NFC の新機能」です。
treastrain / Tanaka Ryoga
July 09, 2020
Tweet
Share
More Decks by treastrain / Tanaka Ryoga
See All by treastrain / Tanaka Ryoga
Mastering AsyncSequence - 使う・作る・他のデザインパターン(クロージャ、Delegate など)から移行する
treastrain
5
2.5k
Firebase Apple SDK 年間ダイジェスト: 2023年 / Firebase Apple SDK Annual Digest: 2023
treastrain
1
1.8k
Combine・sink(RxSwift・subscribe)では Task を作らないようにして async なメソッドを呼ぶ / Do not create a Task inside a Combine/sink (RxSwift/subscribe) closure when calling an async method there
treastrain
2
990
その Swift コード、 こう書き換えてみないか / Polishing your Swift code with me!
treastrain
2
8.3k
存在型に `any` を付けていないときにコンパイルエラーにする / How to produce a compile error when writing an existential type without the `any` keyword
treastrain
1
4.6k
Bitrise Pipelines に移行して、クレジットを節約しながら並列でビルド・テストを回す / Migrate to Bitrise Pipelines and save credits while run builds and tests in parallel
treastrain
0
2.3k
詳解 Core NFC - NFC を用いた iOS App 開発のてびき / Demystify Core NFC - A guide to iOS App Dev using NFC
treastrain
5
4.1k
プロフィールページ(ポートフォリオサイト)を Swift-DocC で作れるか? / Can we create a profile page (portfolio site) in Swift-DocC?
treastrain
1
260
あらゆる情報を 楽に正しく String にフォーマットする 〜令和2021年から脱却せよ〜 / Easily and correctly format any information into a String
treastrain
6
2.1k
Other Decks in Programming
See All in Programming
fs2-io を試してたらバグを見つけて直した話
chencmd
0
220
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
660
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
Security_for_introducing_eBPF
kentatada
0
110
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1.4k
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
Featured
See All Featured
Building Applications with DynamoDB
mza
91
6.1k
Faster Mobile Websites
deanohume
305
30k
Site-Speed That Sticks
csswizardry
2
190
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Side Projects
sachag
452
42k
Visualization
eitanlees
146
15k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Why Our Code Smells
bkeepers
PRO
335
57k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Transcript
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE MPWF@TXJGU ू·Ε4XJGU͖ʂ4XJGUѪձεϐϯΦϑ88%$ηογϣϯཁձ!0OMJOF+VMZ $PSF/'$ʹؔ͢Δ৽ػೳ 8IBUTOFXJO$PSF/'$ USFBTUSBJO5BOBLB3ZPHB !USFBTUSBJO
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE USFBTUSBJO5BOBLB3ZPHB 4XJGU J04 XBUDI04 $PSF/'$ 044 ɹɹɹɹɹɹɹɹɹɹ!USFBTUSBJOɹIUUQTUSFUKQ
ߴઐʢʣେֶʢʣ৽ଔʢʣ ੜ·Εͯ͡Ίͯຊ֨తʹऔΓΜͩ ϓϩάϥϛϯάݴޠ4XJGU ࣗݾհ
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE +BQBO/'$3FBEFS J1IPOFͰిࢠϚωʔͷ ߴɾར༻ཤྺͷಡΈऔΓ J1IPOFͰಡΈऔͬͨཤྺΛ J$MPVEܦ༝ͰଞͷσόΠε͔Β֬ೝͰ͖Δ ݄ϦϦʔεɹμϯϩʔυ, !+BQBO/'$3FBEFS J1IPOFͰిࢠϚωʔͷߴΛνΣοΫ
J04"QQ
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE IUUQTHJUIVCDPNUSFBTUSBJO53&5+BQBO/'$3FBEFS +BQBO/'$3FBEFSͷίΞ෦Λ044Խͨ͠ϥΠϒϥϦ ӡస໔ڐূϚΠφϯόʔΧʔυͷҰ෦༰ͷಡΈऔΓ *OJUJBMDPNNJU݄ɹ4UBST!݄࣌ 53&5+BQBO/'$3FBEFS .*5-JDFODF 044-JCSBSZ
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE /FBS'JFME$PNNVOJDBUJPO ۙڑແઢ௨৴
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ৗʹ༹͚ࠐΉ/'$ ͋ͳͨͷपΓʹ/'$ w ඇ৮ܾࡁ ΫϨδοτΧʔυͷίϯλΫτϨεܾࡁ ϓϦϖΠυܕͷిࢠϚωʔʢަ௨ܥɺҰൠతͳফඅܥʣ w ຊਓ֬ೝ ݸਓ൪߸ʢϚΠφϯόʔʣΧʔυɹɹӡస໔ڐূɹɹύεϙʔτ
ֶੜূɹɹࣾһূ w σʔλͷަ "OESPJE#FBN "OESPJE*$4d1JF
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE J1IPOFͰ/'$Λ͏ $PSF/'$
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE "QQ$MJQTͰ$PSF/'$Θͳ͍ J04Ͱ͑ΔίϯύΫτͳ"QQ w "QQ$MJQTΛ։͘ w /'$ w 23ίʔυ w
Ϛοϓʢۙͷݕࡧʣ w 4JSJ͔ΒͷఏҊ w 4BGBSJ w ϝοηʔδ w "QQ$MJQίʔυ w /'$ɾ23ίʔυͷத 6OJWFSTBM-JOLT w J04ଆ͕ಡΈऔͬͯॲཧ͢Δ $PSF/'$ͷ࣮ඞཁͳ͠
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE $PSF/'$ʹؔ͢Δ৽ػೳ 8IBUTOFXJO$PSF/'$ XXED w $PSF/'$ͷ֓ཁ 0WFSWJFX w 4XJGUͰͷߏจͷมߋ 4ZOUBYDIBOHFT
w *40λά͚ͷϝιουΛՃ *40BEEJUJPOT
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE $PSF/'$ʹؔ͢Δ৽ػೳ 8IBUTOFXJO$PSF/'$ XXED w $PSF/'$ͷ֓ཁ 0WFSWJFX w 4XJGUͰͷߏจͷมߋ 4ZOUBYDIBOHFT
w *40λά͚ͷϝιουΛՃ *40BEEJUJPOT
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE 3FTVMUΛͬͨ4XJGUߏจ .PEFSO4XJGUTZOUBYXJUI3FTVMU w J04ҎલͷNFCFeliCaTagͷྫ &YBNQMFPGNFCFeliCaTagCFGPSFJ04 detectedFeliCaTag.readWithoutEncryption( serviceCodeList: serviceCodeList,
blockList: blockList) { ( statusFlag1: Int, statusFlag2: Int, blockData: [Data], error: Error?) in if let error = error { // Handle error. return } // Handle status flag 1, status flag 2 and block data }
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE 3FTVMUΛͬͨ4XJGUߏจ .PEFSO4XJGUTZOUBYXJUI3FTVMU w J04Ҏ߱ͷNFCFeliCaTagͷྫ &YBNQMFPGNFCFeliCaTagBGUFSJ04 detectedFeliCaTag.readWithoutEncryption( serviceCodeList: serviceCodeList,
blockList: blockList) { ( response: Result<(NFCFeliCaStatusFlag, [Data]), Error>) in switch response { case .success((let statusFlag, let blockData)): // Handle NFCFeliCaStatusFlag object and block data case .failure(let error): // Handle Error object. } }
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE detectedFeliCaTag.readWithoutEncryption( serviceCodeList: serviceCodeList, blockList: blockList) { ( statusFlag1: Int,
statusFlag2: Int, blockData: [Data], error: Error?) in if let error = error { session.invalidate(errorMessage: error.localizedDescription) } guard statusFlag1 == 0x00, statusFlag2 == 0x00 else { session.invalidate( errorMessage: "εςʔλεϑϥά͕ΤϥʔΛ͍ࣔͯ͠·͢ɻ\(statusFlag1), \(statusFlag2)") return } let data = blockData.first! let balance = Int(data[11]) + Int(data[12]) << 8 session.alertMessage = "ߴ: ¥\(balance)" session.invalidate() } ަ௨ܥ*$ΧʔυͷߴΛಡΈऔΔ J04Ҏલͷ߹ɹcompletionHandler
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE detectedFeliCaTag.readWithoutEncryption( serviceCodeList: serviceCodeList, blockList: blockList) { ( response: Result<(NFCFeliCaStatusFlag,
[Data]), Error>) in switch response { case .success((let statusFlag, let blockData)): guard statusFlag.statusFlag1 == 0x00, statusFlag.statusFlag2 == 0x00 else { session.invalidate(errorMessage: "εςʔλεϑϥά͕ΤϥʔΛ͍ࣔͯ͠·͢ɻ\(statusFlag)") return } let data = blockData.first! let balance = Int(data[11]) + Int(data[12]) << 8 session.alertMessage = "ߴ: ¥\(balance)" session.invalidate() case .failure(let error): session.invalidate(errorMessage: error.localizedDescription) } } ަ௨ܥ*$ΧʔυͷߴΛಡΈऔΔ J04Ҏલͷ߹ɹresultHandler
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE Մಡੑ্ͷͨΊͷFOVNͷมߋ .PSFEFTDSJQUJWFFOVNT w FOVNͷ໊শมߋ 3FOBNFTPGUIFTFFOVNT w PollingRequestCodeNFCFeliCaPollingRequestCode w PollingTimeSlot
NFCFeliCaPollingTimeSlot w EncryptionId NFCFeliCaEncryptionId w NFCISO15693ɺNFCISO7816͚ʹ໊শมߋɾՃ͋Γ 0UIFSOFXFOVNT
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ࠓΠϯύΫτগͳΊ J04Ͱͷ$PSF/'$ͷϝιουՃͱൺֱͯ͠ w J04Ͱͷ$PSF/'$ʮωΠςΟϒλάΞΫηεͷՃʯ J04·ͰܾΊΒΕͨϑΥʔϚοτʢ/%&'ʣͷΈ ωΠςΟϒϓϩτίϧʢ*40ɺ'FMJ$Bɺ.*'"3&ͳͲʣ͕͑ΔΑ͏ʹ ɹిࢠϚωʔͷಡΈऔΓɺνϟʔδ ɹϚΠφϯόʔΧʔυͷಡΈऔΓɺॻ͖ࠐΈ
w J04Ͱ4XJGUͰͷߏจมߋͱ*40λά͚ͷػೳՃ *40*&$ʹରԠ ਤॻؗͷຊͷλάͳͲ
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ئ͍Θͣ "QQMF8BUDIͰ$PSF/'$͕͑ΔΑ͏ʹʜͳΒͳ͔ͬͨ USFBTUSBJO5BOBLB3ZPHB !USFBTUSBJO ͍ͬͪͭ͜ͰେৎͰ͢Αʜʁ"QQMF͞Μʜʜʁ 88%$ΑΖ͓͘͠ئ͍͠·͢Ͷʜʜʜʁ ޕޙu݄u5XFFU%FDL
$PQZSJHIUUSFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ࢀߟใ ͋Γ͕ͱ͏͍͟͝·ͨ͠ w ຊεϥΠυ4QFBLFS%FDLʹͯӾཡͰ͖·͢ IUUQTTQFBLFSEFDLDPNUSFBTUSBJO w ຊεϥΠυͰͷαϯϓϧίʔυΛ(JU)VC(JTUͰެ։͍ͯ͠·͢ IUUQTHJTUHJUIVCDPNUSFBTUSBJOGFDFGBCFFD w
88%$7JEFPT w $PSF/'$&OIBODFNFOUT88%$ IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED w 8IBUTOFXJO$PSF/'$88%$ IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED