使用 iPhone 6 / iOS 8 读取 NFC 标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25753473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reading NFC Tags with iPhone 6 / iOS 8
提问by Bryan C
Now that Apple just announced the iPhone 6 will have an NFC chip, does anyone know if iOS 8 will enable reading/detecting RFID tags for the iPhone 6 device? Anyone have any details to share on this?
现在苹果刚刚宣布 iPhone 6 将配备 NFC 芯片,有谁知道 iOS 8 是否会为 iPhone 6 设备启用读取/检测 RFID 标签?任何人有任何细节可以分享吗?
回答by grundyoso
The iPhone6/6s/6+ are NOT designed to read passive NFC tags (aka Discovery Mode). There's a lot of misinformation on this topic, so I thought to provide some tangible info for developers to consider. The lack of NFC tag read support is not because of software but because of hardware. To understand why, you need to understand how NFC works. NFC works by way of Load Modulation. That means that the interrogator (PCD) emits a carrier magnetic field that energizes the passive target (PICC). With the potential generated by this carrier field, the target then is able to demodulate data coming from the interrogator and respond by modulating data over top of this very same field. The key here is that the target never creates a field of its own.
iPhone6/6s/6+ 并非设计用于读取无源 NFC 标签(又名发现模式)。关于这个主题有很多错误信息,所以我想提供一些有形的信息供开发人员考虑。缺少NFC标签读取支持不是因为软件,而是因为硬件。要了解原因,您需要了解 NFC 的工作原理。NFC 通过负载调制方式工作。这意味着询问器 (PCD) 会发射一个载波磁场,为被动目标 (PICC) 提供能量。有了这个载波场产生的电势,目标就能够解调来自询问器的数据,并通过在这个非常相同的场上调制数据来做出响应。这里的关键是目标永远不会创建自己的字段。
If you look at the iPhone6 teardown and parts list you will see the presence of a very small NFC loop antenna as well as the use of the AS3923 booster IC. This design was intended for custom microSD or SIM cardsto enable mobile phones of old to do payments. This is the type of application where the mobile phone presents a Card Emulated credential to a high power contactless POS terminal. The POS terminal acts as the reader, energizing the iPhone6 with help from the AS3923 chip. The AS3923 block diagram clearly shows how the RX and TX modulation is boosted from a signal presented by a reader device. In other words the iPhone6 is not meant to provide a field, only to react to one. That's why it's design is only meant for NFC Card Emulation and perhaps Peer-2-Peer, but definitely not tag Discovery.
如果您查看 iPhone6 的拆解和零件清单,您会看到有一个非常小的 NFC 环形天线以及AS3923 增强器 IC 的使用。此设计适用于自定义 microSD 或 SIM 卡使旧手机能够进行支付。这是手机向高功率非接触式 POS 终端提供 Card Emulated 凭证的应用类型。POS 终端充当阅读器,在 AS3923 芯片的帮助下为 iPhone6 供电。AS3923 框图清楚地显示了 RX 和 TX 调制如何从读取器设备提供的信号中增强。换句话说,iPhone6 并不是要提供一个领域,而只是对一个领域做出反应。这就是为什么它的设计仅适用于 NFC Card Emulation 和 Peer-2-Peer,但绝对不是标记 Discovery。
There are some alternatives to achieving tag Discovery with an iPhone6 using HW accessories. I talk about these integrations and how developers can architect solutions in this blog post. Our low power reader designs open interesting opportunities for mobile engagement that few developers are thinking about.
有一些替代方法可以使用硬件配件在 iPhone6 上实现标签发现。我在这篇博文中讨论了这些集成以及开发人员如何构建解决方案。我们的低功耗阅读器设计为移动参与开辟了有趣的机会,很少有开发人员在考虑。
Disclosure: I'm the founder of Flomio, Inc., a TechStars company that delivers proximity ID hardware, software, and services for applications ranging from access control to payments.
披露:我是Flomio, Inc.的创始人,这是一家 TechStars 公司,为从访问控制到支付的应用程序提供接近 ID 硬件、软件和服务。
Update: This rumor, if true, would open up the possibility for the iPhone to practically support NFC tag Discovery mode. An all glass design would not interfere with the NFC antenna as does the metal back of the current iPhone. We've attempted this design approach --albeit with cheaper materials-- on some of our custom reader designs with success so looking forward to this improvement.
更新:如果这个传言属实,iPhone 就有可能实际支持 NFC 标签发现模式。全玻璃设计不会像当前 iPhone 的金属背面那样干扰 NFC 天线。我们已经在我们的一些定制读卡器设计中尝试了这种设计方法——尽管使用了更便宜的材料——并取得了成功,因此期待这种改进。
Update: iOS11 has announced support for "NFC reader mode" for iPhone7/7+. Details here. API only supports reading NDEF messages (no ISO7816 APDUs) while an app is in the foreground (no background detection). Due out in the Fall, 2017... check the screenshot from WWDC keynote:
更新:iOS11 已宣布支持 iPhone7/7+ 的“NFC 阅读器模式”。详情请看这里。API 仅支持在应用程序处于前台时(无后台检测)读取 NDEF 消息(无 ISO7816 APDU)。将于 2017 年秋季发布……查看 WWDC 主题演讲的截图:
回答by craig.tadlock
From digging into the iOS 8 docs that are available as of Sept 9th 3:30pm there is no mention of developer access to the NFC controller to perform any NFC operations; that includes reading tags, writing tags, pairing, payments, tag emulation... Given its an NXP controller the hardware has the capability to perform these features. They did mention a 3rd party app for the watch that allowed a hotel guest to open their room door with NFC. This is a classic use case for NFC and gives some indication that the NFC controller will be open to developers at some point. Remember, the watch is not supposed to be released until Q1 2015. So for now I'd say it's closed but will be open soon. Given the 'newness' of contactless payments for the general US consumer and the recent security breaches its not surprising Apple wants to keep this closed for a while.
从深入研究截至 9 月 9 日下午 3:30 可用的 iOS 8 文档,没有提到开发人员访问 NFC 控制器以执行任何 NFC 操作;这包括读取标签、写入标签、配对、支付、标签仿真……鉴于其 NXP 控制器,硬件能够执行这些功能。他们确实提到了手表的第 3 方应用程序,该应用程序允许酒店客人使用 NFC 打开房门。这是 NFC 的一个经典用例,并表明 NFC 控制器将在某个时候向开发人员开放。请记住,这款手表要到 2015 年第一季度才会发布。所以现在我想说它已经关闭,但很快就会开放。鉴于“新鲜感”
Disclosure: Im the CEO of GoToTags, an NFC company with obvious vested interest in Apple opening up NFC to developers.
披露:我是GoToTags的首席执行官,这是一家 NFC 公司,对 Apple 向开发者开放 NFC 有着明显的既得利益。
--- Correction & Update ---
--- 更正和更新 ---
The hotel app actually uses Bluetooth, not NFC. NFC is still often used for door unlocking, just not in this one example. NFC could be used if the watch has an open NFC controller.
酒店应用程序实际上使用蓝牙,而不是 NFC。NFC 仍然经常用于开门,只是在这个例子中没有。如果手表具有开放式 NFC 控制器,则可以使用 NFC。
I do know that Apple is aware of all of this and is discussing this with their top developers and stakeholders. There has already been massive negative push back on the lack of support for reading tags. As often the case in the past, I expect Apple to eventually open this up to developers for non-payment related functionality (reading tags, pairing). I do not think Apple will ever allow other wallets though. File sharing will likely be left to AirDrop as well.
我知道 Apple 知道所有这些,并且正在与他们的顶级开发人员和利益相关者讨论这个问题。由于缺乏对阅读标签的支持,已经出现了大量的负面影响。与过去的情况一样,我希望 Apple 最终会向开发人员开放与非支付相关的功能(读取标签、配对)。不过,我认为 Apple 永远不会允许使用其他钱包。文件共享也可能留给 AirDrop。
--- Update on March 23rd 2016 ---
--- 2016 年 3 月 23 日更新---
I am continually asked for updates about this topic, often with people referencing this post. With Apple releasing the iPhone SE, many are again asking why Apple has not supported tag reading yet. In summary Apple is more focused on Apple Pay succeeding than the other use cases for NFC for now. Apple could make a lot of money from Apple Pay, and has less to make from the other uses for NFC. Apple will likely open up NFC tag reading when they feel that consumer trust and security with NFC and Apple Pay is such that it wont put Apple Pay at risk. Further information here.
我不断被要求提供有关此主题的更新,通常人们会参考这篇文章。随着 Apple 发布 iPhone SE,许多人再次询问为什么 Apple 还不支持标签读取。总之,与 NFC 的其他用例相比,Apple 目前更关注 Apple Pay 的成功。苹果可以从 Apple Pay 中赚到很多钱,而从 NFC 的其他用途中赚到的钱却很少。当 Apple 认为消费者对 NFC 和 Apple Pay 的信任度和安全性达到了不会让 Apple Pay 面临风险时,他们可能会开放 NFC 标签读取。更多信息请点击此处。
--- Update on May 24th 2017 ---
--- 2017 年 5 月 24 日更新 ---
A developer in Greece has hacked the iPhone 6s to get it to read NFC tags via the NFC private frameworks; more info & video. While this isn't a long term solution, it provides some guidance on some outstanding question: Is there enough power in the iPhone's NFC controller to power an NFC tag? Looks like the answer is yes. From initial testing the range is a few cm, which isn't too bad. It might also be the power is tunable; this is being investigated at this time. The implications of this are significant. If the older model phones do have enough RF power for tag reading/writing, then when Apple does open up the SDK it means there will be 100Ms of iPhones that can read NFC tags, vs the case where only the new iPhones could.
希腊的一位开发者破解了 iPhone 6s,使其通过 NFC 私有框架读取 NFC 标签;更多信息和视频。虽然这不是一个长期的解决方案,但它为一些悬而未决的问题提供了一些指导:iPhone 的 NFC 控制器中是否有足够的电量来为 NFC 标签供电?看起来答案是肯定的。从最初的测试来看,范围是几厘米,这还不错。也可能是功率可调;目前正在对此进行调查。这带来的影响是显着的。如果旧款手机确实有足够的射频功率来读取/写入标签,那么当 Apple 确实开放 SDK 时,这意味着将有 100 毫秒的 iPhone 可以读取 NFC 标签,而只有新 iPhone 才能读取。
回答by Harry
At the moment, there isn't any open access to the NFC controller. There are currently no NFC APIs in the iOS 8 GM SDK - which would indicate that the NFC capability will be restricted to Apple Pay at launch. This is our understanding.
目前,没有任何对 NFC 控制器的开放访问。目前 iOS 8 GM SDK 中没有 NFC API——这表明 NFC 功能在发布时将仅限于 Apple Pay。这是我们的理解。
Clearly, the NXP chip inside the iPhone 6 is likely to be able to do more so this doesn't mean that additional features (pairing, tag scanning/encoding) will not be added for release or in the near future.
显然,iPhone 6 中的 NXP 芯片可能能够做更多的事情,所以这并不意味着不会在发布时或在不久的将来添加附加功能(配对、标签扫描/编码)。
回答by m4rtin
At the moment, Apple has notopened any access to the embedded NFC chip to developers as suggested by many articles such as these ones :
目前,Apple 还没有向开发人员开放任何对嵌入式 NFC 芯片的访问,如许多文章所建议的,例如:
- Apple Cripples NFC in iPhone 6, 6+ With Developer Banfrom Daily Tech
- Apple Restricting Use of NFC Antenna in iPhone 6 and 6 Plus to Apple Payfrom Mac Rumors
- Apple confirms iPhone 6 NFC chip is only for Apple Pay at launchfrom Cult of Mac
- Apple initially restricts iPhone 6, iPhone 6 Plus NFC chip to Apple Payfrom Tech Times
- 苹果在 iPhone 6、6+ 中削弱了 NFC,Daily Tech 的开发者禁令
- NFC天线的苹果使用限制在iPhone 6和6 Plus来支付苹果在Mac谣言
- 苹果确认 iPhone 6 NFC 芯片仅适用于从 Cult of Mac推出的 Apple Pay
- 苹果最初将 iPhone 6、iPhone 6 Plus NFC 芯片限制为来自 Tech Times 的Apple Pay
The list goes on. The main reason seems (like lots the other hardware features added to the iPhone in the past) that Apple wants to ensure the security of such technology before releasing any API for developers to let them do whatever they want. So at first, they will use it internally for their needs only (such as Apple Pay at launch time).
名单还在继续。主要原因似乎(就像过去添加到 iPhone 的许多其他硬件功能一样),Apple 希望在为开发人员发布任何 API 之前确保此类技术的安全性,让他们为所欲为。所以一开始,他们只会在内部使用它来满足他们的需要(例如在发布时使用 Apple Pay)。
"At the moment, there isn't any open access to the NFC controller," said RapidNFC, a provider of NFC tags. "There are currently no NFC APIs in the iOS 8 GM SDK".
NFC 标签供应商 RapidNFC 表示:“目前,NFC 控制器没有任何开放访问权限。” “目前 iOS 8 GM SDK 中没有 NFC API”。
But eventually, I think we can all agree that they will develop such API, it's only a matter of time.
但最终,我认为我们都同意他们会开发这样的 API,这只是时间问题。
回答by zombie
The ability to read an NFC tag has been added to iOS 11 which only support iPhone 7 and 7 plus
读取 NFC 标签的功能已添加到仅支持 iPhone 7 和 7 plus 的 iOS 11
As a test drive I made this repo
作为试驾,我做了这个repo
First: We need to initiate NFCNDEFReaderSession class
第一:我们需要发起NFCNDEFReaderSession类
var session: NFCNDEFReaderSession?
session = NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: false)
Then we need to start the session by:
然后我们需要通过以下方式开始会话:
session?.begin()
and when done:
完成后:
session?.invalidate()
The delegate (which self should implement) has basically two functions:
委托(它自己应该实现)基本上有两个功能:
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage])
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error)
here is my reference Apple docs
这是我的参考Apple 文档
回答by DonJohnII
The only information currently available is that Apple Pay will be available in ios8, but that doesn't shed any light on whether RFID tags or rather NFC tags specifically will be able to be detected/read.
目前唯一可用的信息是 Apple Pay 将在 ios8 中可用,但这并没有说明是否能够检测/读取 RFID 标签或 NFC 标签。
IMO it would be a shortsighted move not to allow that possibility, but really the money is in Apple Pay, not necessarily in allowing developers access to those features - we've seen it before with tethering, Bluetooth SPP, and diminished access to certain functions.
IMO 不允许这种可能性是一种短视的举动,但实际上钱在 Apple Pay 中,不一定允许开发人员访问这些功能 - 我们之前已经看到过网络共享、蓝牙 SPP 以及对某些功能的访问减少.
...but then again, it's been about 5 hours since the first announcement.
……但话说回来,距离第一次宣布已经过去了大约 5 个小时。
回答by Adrian Sluyters
I think it will be sometime before we get to see access to the NFC as the pure security side of it like for example being able to walk past somebody brush past them and & get your phone to the zap the card details or simply Wave your phone over someone's wallet which They left on the desk.
我认为在我们看到访问 NFC 作为其纯粹的安全方面之前的某个时间,例如能够走过某人刷过他们并让您的手机快速查看卡详细信息或简单地挥动您的手机在他们留在桌子上的某人的钱包上。
I think the first step is for Apple to talk to banks and find more ways of securing cards and NFC before This will be allowed
我认为第一步是让 Apple 在允许之前与银行交谈并找到更多保护卡和 NFC 的方法