I trying to scan nfc tag using the package nfc_manager (nfc_manager: ^3.2.0)
. In Android, it all goes fine but in iOS, I only get the animation ready to scan but no devices are found.
I tried lots of values in the info.plist, I tried this all file also:
https://github.com/okadan/nfc-manager/blob/master/ios/Runner/Info.plist
(comes from a example app from the package).
I also tried with pollingOptions: {NfcPollingOption.iso14443, NfcPollingOption.iso15693}
I have the nfc capability turned ON.
Here goes my fvm flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.11, on macOS 13.3.1 22E772610a darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.77.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
! Doctor found issues in 1 category.
Here goes part of my widget:
class NfcEnableWidget extends StatefulWidget {
final BuildContext contextParent;
const NfcEnableWidget({Key? key, required this.contextParent})
: super(key: key);
@override
_NfcEnableWidgetState createState() => _NfcEnableWidgetState();
}
class _NfcEnableWidgetState extends State<NfcEnableWidget> {
@override
void initState() {
super.initState();
NfcManager.instance.startSession(
// Here. NOTE: all options are specified by default.
//pollingOptions: {NfcPollingOption.iso14443, NfcPollingOption.iso15693},
onDiscovered: (tag) async {
// Do something with the valid tag data
final result = await widget.contextParent
.read<TagOnBoardingCubit>()
.checkNfcCode(tag);
if (result != null) {
ScaffoldMessenger.of(widget.contextParent).showSnackBar(
SnackBar(
content: Text(result),
),
);
}
},
);
}
I'm trying to resolve this issue during the past few weeks.
What's your iOS version? Not all the iPhones support NFC.
The phone must be iPhones with iOS 13 or later and later than iPhone 6.
Read: https://developer.apple.com/design/human-interface-guidelines/nfc
Once, you call startSession, the NFC popup shows up. And it waits until the user tags a NFC.
If it's not a Device or OS problem, then, you might set it up incorrectly.
Add this Info.plist
.
<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
<array>
<string>8005</string>
<string>8008</string>
<string>0003</string>
<string>fe00</string>
<string>90b7</string>
<string>927a</string>
<string>86a7</string>
<string>04D1</string>
<string>80DE</string>
<string>865E</string>
<string>8592</string>
<string>8B5D</string>
<string>8FC1</string>
<string>FE00</string>
</array>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>A000000003101001</string>
<string>A000000003101002</string>
<string>A0000000041010</string>
<string>A0000000042010</string>
<string>A0000000044010</string>
<string>44464D46412E44466172653234313031</string>
<string>D2760000850100</string>
<string>D2760000850101</string>
<string>00000000000000</string>
</array>
And also, check other settings in https://medium.com/@codetrade/implement-nfc-in-flutter-to-transfer-peer-to-peer-data-64efeaa5377c
flutter_nfc_kit can be analternative solution.