ストリーミングはほとんどのブラウザと
Developerアプリで視聴できます。
-
Core NFCに関する新機能
Core NFCはAppでのNFCタグの読み書きを可能にするもので、パーキングメーター、レンタルバイク、自動車の充電ステーションなどのオブジェクトの利便性を高めるのに役立ちます。Core NFCによるISO15693プロトコルや新たなタグ機能のサポートについて知り、Swiftのためのシンタックスの改善の詳細をご覧ください。
リソース
関連ビデオ
WWDC19
-
ダウンロード
Hello and welcome to WWDC.
Hi, my name is Lawrence and I work on NFC software here at Apple.
Today we will go over the changes in our existing APIs. These changes follow some of the new published Swift guidelines.
We have also expanded our APIs for the ISO15693 tag used in NFCTagReaderSession. First, let's start with an overview of Core NFC. You may recall our creative salmon from our last year WWDC presentation.
By the way, his name is Kevin.
Today I have brought Kevin with me and here is the coupon tag.
Core NFC allows your app to read this NFC tag using an iPhone.
NFC is also used in other places, such as on parking meters, scooter rental, electric car charging station, ordering menu in restaurant, et cetera. Core NFC allows an app to read an NFC tag in a session lasting up to 60 seconds. This has been supported on iPhones since the iPhone 7. Beginning on the iPhone XS, tags can also be read in the background while the screen is on, if the NFC forum NDEF message contains a universal link. Once the user has tapped on the notification banner shown on screen that NDEF message will be sent to your application as an NSUserActivity via UIApplicationDelegate restorationHandler. Texts may contain a NFC forum NDEF message or other proprietary data set.
Core NFC supports NDEF reading and writing as well as other native tag protocols.
The easiest path for tag access is to use the NFCNDEFReaderSession.
Core NFC supports NDEF reading and writing as well as other native tag protocols.
The easiest path for tag access is to use the NFCNDEFReaderSession. But Core NFC also supports raw tag communication via ISO7816, FeliCa, MIFARE and ISO15693. Next, let's talk about some changes to the Swift syntax to make it easier to understand your Core NFC code.
Core NFC now adopts the use of the Result enum in our tag APIs, specifically how parameters are returned in our completion handler. Let's look at the ISO7816-tag-send-command as an example. Before iOS 14, the method signature accepts a closure with four arguments as the completion handler. Your application will need to check the optional error object to determine if an error occurs. If the operation succeeds, you may then parse the rest of arguments to collect the results. The new signature in iOS 14 returns a Result enum of either a NFCISO7816-Response-APDU object on success, which is the result of reading the tag, or an error object on a failure. The Result enum can be easily handled using a switch statement as shown.
Now let me show you how it looks in Xcode.
I've opened the NFCFishTag sample project from WWDC 2019. Here, in CouponViewController, the write function is shown in its existing form. Let's replace the send-MIFARE-command using its new Result signature.
Here, in the new code, the data object is handled in this section of a switch statement. An error is handled over here.
We have also made a few changes to the existing enum values to improve readability. For example, the ResolveFlag enum has been changed to refer specifically to ISO15693. Some other new enums have been added as well. Please refer to the documentation for more details. Now we will talk about new capabilities we've added to the NFC-ISO15693 tag protocol. We have added the enhancement defined by the ISO15693 specification third edition 2019. These functions are useful for tags with larger memory sizes and security operations. We have also included a new generic send command if you would like to send arbitrary data packets for your application. Here is a complete list of the enhancement function signatures under the NFC-ISO15693Tag protocol.
We now support the following operations: fast reading multiple blocks, extended write multiple blocks, authenticate, key update, challenge, read buffer, extended get multiple blocks security status, extended fast read multiple blocks and send request.
That's what new in Core NFC this year. We look forward to seeing what you can make with it.
-
-
3:24 - sendCommand
detectedTag.sendCommand(apdu: apdu) { (result: Result<NFCISO7816ResponseAPDU, Error>) in switch result { case .success(let responseAPDU): /// Handle NFCISO7816ResponseAPDU object. case .failure(let error): /// Handle Error object. } }
-
4:06 - sendMiFareCommand
// You need to zero-pad the data to fill the block size if blockData.count < blockSize { blockData += Data(count: blockSize - blockData.count) } let writeCommand = Data([writeBlockCommand, offset]) + blockData tag.sendMiFareCommand(commandPacket: writeCommand) { (response: Result<Data, Error>) in switch (response) { case .success(let responseData): if responseData[0] != successCode { self.readerSession?.invalidate(errorMessage: "Write tag error. Please try again.") return } let newSize = data.count - blockSize if newSize > 0 { self.write(data.suffix(newSize), to: tag, offset: (offset + 1)) } else { self.readerSession?.invalidate() } case .failure(let error): let message = "Write tag error: \(error.localizedDescription). Please try again." self.readerSession?.invalidate(errorMessage: message) } }
-
-
特定のトピックをお探しの場合は、上にトピックを入力すると、関連するトピックにすばやく移動できます。
クエリの送信中にエラーが発生しました。インターネット接続を確認して、もう一度お試しください。