xcode 如何在 iPhone 应用中实现 NFC?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26571115/
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
How to implement NFC in an iPhone app?
提问by PolyglotCode
So I was wondering if anyone knows how I can implement NFC usage into my app. The result I want by using NFC is when someone passes an NFC sensor with their phones in their pocket for example, the action triggers a notification for example but I do not know how to add NFC to the app and how the NFC necessarily interacts with in the iOS system. Also, is the code for NFC implementation available in Swift yet or is it only in Objective C so far? Thanks a lot in advance! Thanks a lot in advance!
所以我想知道是否有人知道我如何在我的应用程序中实现 NFC 使用。我想要使用 NFC 的结果是,例如,当有人将手机放在口袋里通过 NFC 传感器时,该操作会触发通知,但我不知道如何将 NFC 添加到应用程序以及 NFC 必须如何与iOS系统。另外,NFC 实现的代码是否在 Swift 中可用,还是目前仅在 Objective C 中可用?非常感谢!非常感谢!
回答by
NFC is a very new thing for Apple, having only just added the chip to their new phones, 6 and 6 Plus. Unfortunately for you, they have made a decision to add not functionality at all in Xcode, and they have restricted NFC usage to Apple Pay only. That means trying to code a pairing system to Bluetooth speakers or a Touch ID-enabled way of exchanging contacts, URLs, and photos with a tap won't work. However, Apple might in the future allow developing for NFC like they did with the Touch ID sensor in iOS 8. Unfortunately, for now, you won't be able to code for NFC.
NFC 对 Apple 来说是一个非常新的东西,刚刚在他们的新手机 6 和 6 Plus 中添加了芯片。对您来说不幸的是,他们决定在 Xcode 中根本不添加任何功能,并且他们将 NFC 的使用限制为仅 Apple Pay。这意味着尝试将配对系统编码到蓝牙扬声器或通过点击来交换联系人、URL 和照片的启用 Touch ID 的方式将不起作用。但是,Apple 可能在未来允许为 NFC 进行开发,就像他们在 iOS 8 中使用 Touch ID 传感器所做的那样。不幸的是,目前,您将无法为 NFC 编码。
Sorry to be the bearer of bad news,
很抱歉成为坏消息的承载者,
Will
将要
回答by fdqps
If you look past NFC you could get the exact functionality your looking for with iBeacon.
如果您看过去 NFC,您可以通过 iBeacon 获得您正在寻找的确切功能。