Unable to send Mifare commandos on iOS

I have created a Flutter application to scan Mifare DESFire cards on Android and iOS. I have tried using both flutter_nfc_kit and nfc_manager which both use CoreNFC.

On both platforms, I can get the basic information on the card. However, only on Android, I can read data from the card by using Mifare commands. On iOS I am getting a 0B response.

I have the following configuration inside my Runner.entitlements:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>com.apple.developer.nfc.readersession.formats</key>
     <array>
	  <string>TAG</string>
     </array>
</dict>
</plist>

I have added the following keys inside my Info.plist file:

<dict>
    <key>NFCReaderUsageDescription</key>
    <string>Access NFC</string>
    <key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
    <array>
	 <string>D2760000850100</string>
    </array>
    ...
</dict>

However, I have noticed that I will get a different response if I add the D2760000850100 key in the Info.plist file. When I have this key added I get an error when executing a Mifare command: PlatformException(500, Communication error, Tag response error, null)

So for that reason, I decided to remove the key altogether. Now everytime, I execute a Mifare command I end up with the response of 0B. Which does not tell me anything because it is not an official response.

The Mifare command I am using is the select application command: 5A123456 where 123456 is the application ID. As mentioned before this works perfectly on Android.

The only response I can get from the Mifare DESFire card is with an ISO7816 command: 00A4040006D2760000850100. Which is the select application command according to the ISO7816 standard. However, after executing this command I need to authenticate, which requires a complex algorithm.

Is it necessary on iOS to first execute ISO7816 commands, before you can execute Mifare commands?

Adding D2760000850101 (not D2760000850100 like you indicated) will signal the system to treat the MiFare tag as a ISO7816 one.

If you do not include this, then the system will return an NFCTag object that conforms to the MiFare protocol (NFCMiFareTag) and you can send MiFare commands directly.

I cannot help with how Flutter and the libraries you mention implement this, but if in MiFare mode, one must use the sendMiFareCommand(commandPacket:completionHandler:) function in order to send native MiFare commands.

You may want to contact the support channels of the tools you are using to see if they are indeed supporting native MiFare commands correctly in iOS.

Unable to send Mifare commandos on iOS
 
 
Q