Update for iOS 12:
1) If you want to run your app only for iPhone 7 and newer models you can add NFC requirement in Info.plist
:
<key>UIRequiredDeviceCapabilities</key>
<array>
// ... your restrictions
<string>nfc</string>
</array>
With this requirement only the devices with NFC will be able to download our app from App Store.
2) For iPhones older than iPhone 7 and for iPads support you have to also check if Core NFC
is available because it is not included for these devices. That is why you should link Core NFC
framework using Weak Linking:
and then check for Core NFC
availability in code:
var isNFCAvailable: Bool {
if NSClassFromString("NFCNDEFReaderSession") == nil { return false }
return NFCNDEFReaderSession.readingAvailable
}
If isNFCAvailable
returns true
then you can use all the APIs provided by Core NFC
without worrying about your app crash.