On the development of the new features of iOS11 - Core NFC

Beijing 2017.6. At 1:00 on the 6th, held a new session of WWDC, Apple released a beta version iOS11 at the conference, although the official version is still some time before the push, but functional items which caught my attention, namely Apple officially open a part of the development of the NFC interface. Although iphone6 ​​start Apple mobile phone has NFC hardware, but there has been no open development interface, Apple's official Apple Pay applications using the NFC function. It now appears that Apple iOS11 the NFC interface for developers to open, although currently only open to open the document from the NFC to read NFC data without an open interface to write data, but it would be a good start.

This library will be called Apple Core NFC: Apple's official documents address


Core NFC

For detecting the NFC (near field communication) tags and reading information comprising NDEF data.

SDK requires iOS 11.0+


Outline

Your app can read tags through NFC, giving users more information about the content of the object and its physical real-world environment. For example: Your app may be able to give the user information commodity information provider store or exhibit when they visit the museum.

note

At present, only iPhone 7 and iPhone 7 Plus supports reading NFC NDEF tag

Use Core NFC, you can read the 1-5 type NFC tag comprises the NDEF (NFC Data Exchange Format) format of the data. Your app can provide a delegate proxy to read the tag by creating an NFC NDEF reader session objects simultaneously. When the reader session object is a running found NDEF tag that contains information, we will pass this information to its delegate agency. The delegate agency, you can read the message session can handle the situation becomes invalid.

To make your app can detect NFC tag, please refer to the Certificates, Identifiers, and Profiles



Core NFC

Core NFC includes the following


Reader Sessions

Class  NFCNDEFReaderSession

A reader session class detection tag NFC NDEF

Class Details link


Protocol  NFCNDEFReaderSessionDelegate

When this state delegate comprising a reader session message on a set of tags and found relevant NDEF message callback method

Details of the link protocol


Protocol  NFCReaderSessionProtocol

It defines a common interface to interact with the reader session

Details of the link protocol


Protocol  NFCReaderSessionDelegate

This delegate is included to provide information about the callback method NFC reader of an aggregate

Details of the link protocol


Class  NFCReaderSession

It is used to describe a reader session NFC tag for detecting abstract class

Class Details link


NFC Tags

Protocol  NFCTags

NFC or RFID defined attributes (Radio Frequency Identification, RFID) tag

Details of the link protocol


Class  NFCTagCommandConfiguration

This class provides a set of parameters allows you to configure the NFC tag command

Class Details link




NDEF Messages

Class  NFCNDEFMessage

NFC NDEF message type, consisting of a set of payload records

Class Details link


Class  NFCNDEFPayload

This class represents a payload record in the NFC NDEF message

Class Details link


Enum  NFCTypeNameFormat

NFC format enumeration type name, which is part of the NFC NDEF message payload

Details of the link enumeration




Error 

struct  NFCReaderError

Details of the link structure





summary

It seems that only the purest from the document read not write that whole fool detection.

After the conclusion use is to create a NFCNDEFReaderSession object, and then let your example controller VC become his delgate proxy, the proxy method to achieve the system detects that the wait for a callback message nfc

The most important method is to detect callback proxy NDEF message: func readerSession (NFCNDEFReaderSession, didDetectNDEFs: [NFCNDEFMessage])

Message content NDEFs: [NFCNDEFMessage] is an array of objects NFCNDEFMessage

NFCNDEFMessage only a class attribute records: [NFCNDEFPayload], records and an array of objects is located NFCNDEFPayload

That is the real objects stored data is NFCNDEFPayload

NFCNDEFPayload object has four attributes var identifier: Data, var payload: Data, var type: Data, var typeNameFormat: NFCTypeNameFormat

You can see the data payload is the real content, type Data format is binary, so the specific read out what kind of data is only tested to know


Sample Code



Since I have not iphone7 current or iphone7s, so I can not use the real CoreNFC, come back to do more to use and after use later this experience sharing.




Guess you like

Origin blog.csdn.net/qq_26918391/article/details/78053937