Core NFC の新機能 / What's new in Core NFC (WWDC20)

Core NFC の新機能 / What's new in Core NFC (WWDC20)

集まれSwift好き!Swift愛好会スピンオフ WWDC20セッション要約会 @ Online で発表した LT「Core NFC の新機能」です。

Transcript

  1. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE MPWF@TXJGU ू·Ε4XJGU޷͖ʂ4XJGUѪ޷ձεϐϯΦϑ88%$ηογϣϯཁ໿ձ!0OMJOF+VMZ  $PSF/'$ʹؔ͢Δ৽ػೳ 8IBUTOFXJO$PSF/'$ USFBTUSBJO5BOBLB3ZPHB !USFBTUSBJO 

  2. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE  USFBTUSBJO5BOBLB3ZPHB 4XJGU J04 XBUDI04 $PSF/'$ 044 ɹɹɹɹɹɹɹɹɹɹ!USFBTUSBJOɹIUUQTUSFUKQ 

    ߴઐʢʣ‎େֶʢʣ‎৽ଔʢʣ ੜ·Εͯ͸͡Ίͯຊ֨తʹऔΓ૊Μͩ ϓϩάϥϛϯάݴޠ4XJGU  ࣗݾ঺հ
  3. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE  +BQBO/'$3FBEFS J1IPOFͰిࢠϚωʔͷ ࢒ߴɾར༻ཤྺͷಡΈऔΓ J1IPOFͰಡΈऔͬͨཤྺΛ J$MPVEܦ༝ͰଞͷσόΠε͔Β֬ೝͰ͖Δ ೥݄ϦϦʔεɹμ΢ϯϩʔυ਺, !+BQBO/'$3FBEFS J1IPOFͰిࢠϚωʔͷ࢒ߴΛνΣοΫ

    J04"QQ
  4. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE IUUQTHJUIVCDPNUSFBTUSBJO53&5+BQBO/'$3FBEFS +BQBO/'$3FBEFSͷίΞ෦෼Λ044Խͨ͠ϥΠϒϥϦ ӡస໔ڐূ΍ϚΠφϯόʔΧʔυͷҰ෦಺༰ͷಡΈऔΓ΋ *OJUJBMDPNNJU೥݄೔ɹ4UBST!೥݄೔࣌఺  53&5+BQBO/'$3FBEFS .*5-JDFODF 044-JCSBSZ

  5. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE /FBS'JFME$PNNVOJDBUJPO ۙڑ཭ແઢ௨৴ 

  6. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ೔ৗʹ༹͚ࠐΉ/'$ ͋ͳͨͷपΓʹ΋/'$ w ඇ઀৮ܾࡁ ‎ΫϨδοτΧʔυͷίϯλΫτϨεܾࡁ ‎ϓϦϖΠυܕͷిࢠϚωʔʢަ௨ܥɺҰൠతͳফඅܥʣ w ຊਓ֬ೝ ‎ݸਓ൪߸ʢϚΠφϯόʔʣΧʔυɹɹӡస໔ڐূɹɹύεϙʔτ

    ‎ֶੜূɹɹࣾһূ w σʔλͷަ׵ ‎"OESPJE#FBN "OESPJE*$4d1JF 
  7. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE J1IPOFͰ/'$Λ࢖͏ ‎$PSF/'$ 

  8. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"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/'$ͷ࣮૷͸ඞཁͳ͠ 
  9. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE $PSF/'$ʹؔ͢Δ৽ػೳ 8IBUTOFXJO$PSF/'$ XXED w $PSF/'$ͷ֓ཁ 0WFSWJFX w 4XJGUͰͷߏจͷมߋ 4ZOUBYDIBOHFT

    w *40λά޲͚ͷϝιουΛ௥Ճ *40BEEJUJPOT 
  10. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE $PSF/'$ʹؔ͢Δ৽ػೳ 8IBUTOFXJO$PSF/'$ XXED w $PSF/'$ͷ֓ཁ 0WFSWJFX w 4XJGUͰͷߏจͷมߋ 4ZOUBYDIBOHFT

    w *40λά޲͚ͷϝιουΛ௥Ճ *40BEEJUJPOT 
  11. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"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 }
  12. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"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. } }
  13. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"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 
  14. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"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 
  15. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE Մಡੑ޲্ͷͨΊͷFOVNͷมߋ .PSFEFTDSJQUJWFFOVNT w FOVNͷ໊শมߋ 3FOBNFTPGUIFTFFOVNT w PollingRequestCode‎NFCFeliCaPollingRequestCode w PollingTimeSlot

    ‎NFCFeliCaPollingTimeSlot w EncryptionId ‎NFCFeliCaEncryptionId w NFCISO15693ɺNFCISO7816޲͚ʹ΋໊শมߋɾ௥Ճ͋Γ 0UIFSOFXFOVNT 
  16. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ࠓ೥͸ΠϯύΫτগͳΊ J04Ͱͷ$PSF/'$ͷϝιου௥Ճͱൺֱͯ͠ w J04Ͱͷ$PSF/'$ʮωΠςΟϒλάΞΫηεͷ௥Ճʯ ‎J04·Ͱ͸ܾΊΒΕͨϑΥʔϚοτʢ/%&'ʣͷΈ ‎ωΠςΟϒϓϩτίϧʢ*40ɺ'FMJ$Bɺ.*'"3&ͳͲʣ͕࢖͑ΔΑ͏ʹ ɹ‎ిࢠϚωʔͷಡΈऔΓɺνϟʔδ ɹ‎ϚΠφϯόʔΧʔυͷಡΈऔΓɺॻ͖ࠐΈ 

    w J04Ͱ͸4XJGUͰͷߏจมߋͱ*40λά޲͚ͷػೳ௥Ճ ‎*40*&$ʹରԠ ‎ਤॻؗͷຊͷλάͳͲ
  17. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ئ͍׎Θͣ "QQMF8BUDIͰ$PSF/'$͕࢖͑ΔΑ͏ʹʜͳΒͳ͔ͬͨ USFBTUSBJO5BOBLB3ZPHB !USFBTUSBJO ͬͪ͜͸͍ͭͰ΋େৎ෉Ͱ͢Αʜʁ"QQMF͞Μʜʜʁ 88%$ΑΖ͓͘͠ئ͍͠·͢Ͷʜʜʜʁ ޕޙu೥݄೔u5XFFU%FDL 

  18. $PQZSJHIU˜USFBTUSBJO5BOBLB3ZPHBɹ"MMSJHIUTSFTFSWFE ࢀߟ৘ใ ͋Γ͕ͱ͏͍͟͝·ͨ͠ w ຊεϥΠυ͸4QFBLFS%FDLʹͯӾཡͰ͖·͢ IUUQTTQFBLFSEFDLDPNUSFBTUSBJO w ຊεϥΠυͰͷαϯϓϧίʔυΛ(JU)VC(JTUͰެ։͍ͯ͠·͢ IUUQTHJTUHJUIVCDPNUSFBTUSBJOGFDFGBCFFD w

    88%$7JEFPT w $PSF/'$&OIBODFNFOUT88%$ IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED w 8IBUTOFXJO$PSF/'$88%$ IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED