Flutter plugin for accessing the NFC features on Android and iOS.

Overview

nfc_manager

Flutter plugin for accessing the NFC features on Android and iOS.

Note: This plugin depends on NFCTagReaderSession (requires iOS 13.0 or later) and NfcAdapter#enableReaderMode (requires Android API level 19 or later).

Setup

Android Setup

iOS Setup

Usage

Handling Session

// Check availability
bool isAvailable = await NfcManager.instance.isAvailable();

// Start Session
NfcManager.instance.startSession(
  onDiscovered: (NfcTag tag) async {
    // Do something with an NfcTag instance.
  },
);

// Stop Session
NfcManager.instance.stopSession();

Handling Platform Tag

The following platform-tag-classes are available:

  • Ndef
  • FeliCa (iOS only)
  • Iso7816 (iOS only)
  • Iso15693 (iOS only)
  • MiFare (iOS only)
  • NfcA (Android only)
  • NfcB (Android only)
  • NfcF (Android only)
  • NfcV (Android only)
  • IsoDep (Android only)
  • MifareClassic (Android only)
  • MifareUtralight (Android only)
  • NdefFormatable (Android only)

Obtain an instance by calling the factory constructor from() on the class. For example:

Ndef ndef = Ndef.from(tag);

if (ndef == null) {
  print('Tag is not compatible with NDEF');
  return;
}

// Do something with an Ndef instance

Please see the API Doc for more details.

Real-World-App

See this repo which is a Real-World-App demonstrates how to use this plugin.

Comments
  • iOS ISO15693 read Multiple Blocks

    iOS ISO15693 read Multiple Blocks

    I always get "Invalid Parameters" & "custom Command code must be between 0xA0 to 0xDF"

    What I do: Set<ISO15693RequestFlag> requestFlags = new Set(); requestFlags.add(ISO15693RequestFlag.highDataRate); requestFlags.add(ISO15693RequestFlag.address); Uint8List command = new Uint8List(10); command[0] = (182); command[1] = (51); command[2] = (59); command[3] = (167); command[4] = (0); command[5] = (38); command[6] = (2); command[7] = (224); command[8] = (165); command[9] = (4); Uint8List response = await iso15693.customCommand(requestFlags: requestFlags, commandCode: 23, parameters: command); debugPrint('Response: ' + response.toString());

    equals to the command: 22 23 B6 33 3B A7 00 26 02 E0 A5 04 right?

    But I can't get any response.

    enhancement 
    opened by Lastone17 14
  • Exception: decodeObjectForKey: class

    Exception: decodeObjectForKey: class "NFFieldNotification" not loaded or does not exist

    IOS version: 13.2.3

    Error occurs after initiation of Read/ Write events on both devices.

    [xpc.exceptions] NSXPCConnection: connection to service on pid 85 named com.apple.nfcd.service.corenfc: Exception caught during decoding of received selector didDetectExternalReaderWithNotification:, dropping incoming message.

    Exception: Exception while decoding argument 0 (# 2 of invocation): Exception: decodeObjectForKey: class "NFFieldNotificationECP1_0" not loaded or does not exist

    Note: Events are getting triggered, Ready To scan Popup is disappearing.

    opened by 1993-tensa-g 12
  • NFC transceive fails at second transmission on Android.

    NFC transceive fails at second transmission on Android.

    I try to use the NfcV class to transmit some commands to a corresponding tag. I registered the following function as callback for the onDiscovered events. The result is a correct answer on the first try and an exception on the second try. Did I do it wrong?

    Future callbackFunction(NfcTag tag) async {
      final nfcVtag = NfcV.fromTag(tag);
      final cmd = [0x02, 0x20, 0x00].toList();
      try {
        final answer = await nfcVtag.transceive(Uint8List.fromList(cmd));
        debugPrint('First answer ' + answer.toString());
      } catch (e) {
        debugPrint('Exception on first try: ' + e.toString());
      }
      try {
        final answer = await nfcVtag.transceive(Uint8List.fromList(cmd));
        debugPrint('Second answer ' + answer.toString());
      } catch (e) {
        debugPrint('Exception on second try: ' + e.toString());
      }
    }
    

    Output:

    I/flutter (17066): First answer [0, 167, 19, 240, 84, 5, 0, 3, 101]
    I/flutter (17066): Exception on second try: PlatformException(not_found, Tag is not found., null)
    
    opened by markus-oehme-pg40 9
  • iOS popover cancel button event

    iOS popover cancel button event

    Hi @okadan

    first of all great work!

    I am using your package in a project where I read a NfcTag and later use the tag id to call some server logic. Overall I am using the BLoC-pattern and I am wondering if there is an option to catch the "on cancel"-event when you tap the button on the Nfc-Popover in iOS. I differentiate between two states IsReadyToReadNfc and ReadingNfc. Depending on the state I have a button and want to display either "Start Scanning" or "Scanning..."

    enhancement 
    opened by eddiesTime 6
  • iOS iso7816 sendCommand Response Error

    iOS iso7816 sendCommand Response Error

    I'm working on reading an iso1443-4 card on iOS. It works well on Swift code but failed in the flutter project.

    Code with flutter-nfc-manager

    iso7816Tag.sendCommandRaw(Uint8List.fromList([0x00, 0xA4, 0x04, 0x00, 0x08, 0x50, 0x41, 0x59, 0x2E, 0x54, 0x49, 0x43, 0x4C, 0x00])).then((value) =>
    {
       print("select App response ${value}")
    });
    

    flutter-nfc-manager Response

    flutter: select App response []
    [CoreNFC] 00000002 8001cb40 -[NFCTagReaderSession setAlertMessage:]:90  (null)
    

    The command is correct, it works well in Xcode with swift.

    Code with Swift

    let selectApp : NFCISO7816APDU = NFCISO7816APDU(data: Data.init([0x00, 0xA4, 0x04, 0x00, 0x08, 0x50, 0x41, 0x59, 0x2E, 0x54, 0x49, 0x43, 0x4C, 0x00]))!
                
    session.connect(to: tag0!) { (e: Error?) in tag?.sendCommand(apdu: selectApp, completionHandler: { (data: Data, sw1: UInt8, sw2: UInt8, error: Error?) in
      print("selectApp APDU Result \(data.hexDescription)")
    })
    }
    

    Swift Response

    selectApp APDU Result 6f3484085041592e5449434ca5289f0801029f0c21ffffffffffffffff000000000000000000000000000000002019082400000186a0
    

    Please help to confirm the issues. πŸ™

    opened by whywilson 5
  • Will there be any implementation of getting the UID/ID from an NFC Tag?

    Will there be any implementation of getting the UID/ID from an NFC Tag?

    Hello, I'm trying to make a login app which utilises the UID/ID of an NFC Card/Tag to log the user in. I can obtain the value in Android using nfc_in_flutter (another package) but I cant use that here because it doesn't seem to even register the nfc card being infront of the phone. Only yours (nfc_manager) works and actually detects the card when placed infront of the phone.

    The NFC tag I'm using currently is ISO14443, so I set the polling option to that within session start.

    And so I ask, will there be any implementation of getting UID/ID from NFC tags? Because currently on session start of the NFC Manager, once we hover the nfc tag over, we get back {mifare: {identifier: [4, 40, 252, 242, 37, 94, 129], historicalBytes: [], mifareFamily: 2}, ndef: {isWritable: true, maxSize: 137}} the data received seems to be everything but the ID, which is a bit weird.

    Thanks!

    opened by jarren-meep 5
  • Read data from the sector?

    Read data from the sector?

    Hi,

    I am able to see the information like "id", "nfca", "maxTransceiveLength", "mifareclassic". Under "mifareclassic" there is block count, maxtransceivelength, sectorcount, size and timeout information.

    Are we able to read the data from different sector? I wish to retrieve the information in the card.

    Thanks!

    opened by speedlightwp 5
  • How to open the app when nfc is detected

    How to open the app when nfc is detected

    I am trying to open a certain screen when the nfc is detected , i have tried the workmanager but it didn't work , after reaserch i found this artice but i'm not sure how to use it for my own purpose https://muetsch.io/how-to-receive-sharing-intents-in-flutter.html

    opened by dfourcfive 4
  • Issue with iOS 14.4.1 on iPhone 7

    Issue with iOS 14.4.1 on iPhone 7

    I tried out your demo code and also checked out your demo application on my iPhone 7 iOS 14.4.1 and it is not working.

    2021-03-19 11:28:29.884901+0100 Runner[403:8791] [CoreNFC] 00000002 83700c20 -[NFCHardwareManager queueReaderSession:sessionConfig:completionHandler:]:96 error=Error Domain=NFCError Code=203 "System resource unavailable" UserInfo={NSLocalizedDescription=System resource unavailable} 2021-03-19 11:28:29.885297+0100 Runner[403:8791] [CoreNFC] 00000002 80558870 -[NFCTagReaderSession beginSessionWithConfig:]:365 error:Error Domain=NFCError Code=203 "System resource unavailable" UserInfo={NSLocalizedDescription=System resource unavailable}, errorCode: 0xcb

    This is the exception with your example code.

    opened by torgebauer 4
  • QUESTION: Reading previous write Tag Data

    QUESTION: Reading previous write Tag Data

    Hi, i like to learn about nfc, i use write tag with your sample and get this response: Success to "Ndef Write"

    but when i read the tag i get this:

    {id: [249, 109, 254, 163], nfca: {atqa: [4, 0], maxTransceiveLength: 253, sak: 8, timeout: 618}, mifareclassic: {blockCount: 64, maxTransceiveLength: 253, sectorCount: 16, size: 1024, timeout: 618, type: 0}, ndef: {cachedMessage: {records: [{typeNameFormat: 1, type: [84], identifier: [], payload: [2, 101, 110, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]}, {typeNameFormat: 1, type: [85], identifier: [], payload: [4, 102, 108, 117, 116, 116, 101, 114, 46, 100, 101, 118]}, {typeNameFormat: 2, type: [116, 101, 120, 116, 47, 112, 108, 97, 105, 110], identifier: [], payload: [72, 101, 108, 108, 111]}, {typeNameFormat: 4, type: [99, 111, 109, 46, 101, 120, 97, 109, 112, 108, 101, 58, 109, 121, 116, 121, 112, 101], identifier: [], payload: [109, 121, 100, 97, 116, 97]}]}, canMakeReadOnly: false, isWritable: true, maxSize: 716, type: com.nxp.ndef.mifareclassic}}

    how i do to process the payload to see the info as was wrote?

    thanks for your help!

    opened by alexlovar 4
  • Error build for Iphone 14

    Error build for Iphone 14

    Hello when i want to build my project with iphone 14 which uses NFC_Manager, i obtain this error:

    Swift Compiler Error (Xcode): Stored properties cannot be marked potentially unavailable with '@available'
    /flutter/.pub-cache/hosted/pub.dartlang.org/nfc_manager-3.1.1/ios/Classes/SwiftNfcManagerPlugin.swift:6:3
    

    Any idea ? Thx

    opened by redDwarf03 3
  • Nfc advance tools

    Nfc advance tools

    Hello,

    Is there any option to reproduce the behavior from Nfc Tools Application?

    I am able with this package, to read as well as write ndef data. However, I am concerned with more advanced commands that allow me to get information from specific blocks.

    In the Nfc tools application -> Others-> Advanced NFC commands

    I need to execute the commands for Tag Type 2: Read 16 bytes. Specifically, the commands in question are 30:04 and 30:4f.

    I know that the basic tag returned in the onDiscovered callback does not have this information. I checked this by scanning the same tag a bunch of times. Each time I changed the data, on the block I was interested in.

    With the help of the previously mentioned "Nfc Tools" application, I was easily able to execute this command and read the changes I was interested in.

    I have not found so far the option to perform this type of command, in any Nfc library for fluter. I'm afraid I'll have to write an implementation for iOS myself, but I don't know Swift or Objective-C very well.

    Have I missed something, or am I doomed to write it myself?

    opened by MlecznyU 0
  • iOS 12 Crash

    iOS 12 Crash

    I can't get my App with NFC Manager running on iOS 12.

    I get that error message in Xcode:

    dyld: Library not loaded: /System/Library/Frameworks/CoreNFC.framework/CoreNFC Referenced from: /private/var/containers/Bundle/Application/9F305E2C-0F10-4AE4-B80E-686383E1FFC7/Runner.app/Frameworks/nfc_manager.framework/nfc_manager Reason: image not found

    I am using nfc_manager: ^3.2.0 and Flutter 3.3.7

    opened by marcoheine 0
  • Added restartPolling on iOS to be able to keep polling for multiple NFC tags after detecting one.

    Added restartPolling on iOS to be able to keep polling for multiple NFC tags after detecting one.

    Summary

    Finding multiple NFC tags on iOS is pretty clunky business, one would have to show the scan modal multiple times which does not lead to a good user experience. NFCTagReaderSession does however have the option to restart polling after finding a tag, thus making it possible to scan more than one NFC tag per session.

    I did add the variable shouldInvalidateAfterFirstRead so the library user can specify if they want this enabled, default behaviour is disabled and it is optional so we won't disturb any existing uses. The name shouldInvalidateAfterFirstRead is based on a similar function in NFCNDEFReaderSession.

    How to test

    In the example change _tagRead to the following:

     void _tagRead() {
        NfcManager.instance.startSession(invalidateAfterFirstRead: false, onDiscovered: (NfcTag tag) async {
          result.value = tag.data;
          // NfcManager.instance.stopSession();
        });
      }
    

    After this you can spin up the example iOS app and test the scanning of multiple items on one request.

    opened by CollinHemeltjen 0
  • Possibility to disable NFC platform sound

    Possibility to disable NFC platform sound

    Is it possible, at the current stage, to disable the default platform sounds? I can see that the library depends on API 19 that allows to disable the sounds in theory: https://developer.android.com/reference/android/nfc/NfcAdapter.html#FLAG_READER_NO_PLATFORM_SOUNDS

    opened by tratteo 0
Releases(v3.0.0)
Flutter beacons plugin for Android and iOS.

Beacons Flutter plugin to work with beacons. Supports Android API 16+ and iOS 8+. Features: Automatic permission management Ranging Monitoring (includ

Loup 76 Jan 6, 2023
Ready for Building Production-Ready Healthcare/ Doctor Consult Android and iOS app UI using Flutter.

Production-Ready Doctor Consultant App - Flutter UI Watch it on YouTube Packages we are using: flutter_svg: link Complete Source code (Patreon) In thi

Abu Anwar 211 Jan 1, 2023
ESC/POS (thermal, receipt) printing for Flutter & Dart (Android/iOS)

esc_pos_bluetooth The library allows to print receipts using a Bluetooth printer. For WiFi/Ethernet printers, use esc_pos_printer library. TODO (PRs a

Andrey 175 Jan 6, 2023
This Android/IOS application intends to help users to get an early notification for slot availability for Covid19 vaccination.

Cowin Slot Reminder Objective: This Android/IOS application intends to help users to get an early notification for slot availability for Covid19 vacci

null 6 Oct 7, 2022
iOS App to Record Daily Sun Intake

Why Suncheck 당신은 ν•˜λ£¨μ— ν•΄λ₯Ό μ–Όλ§ˆλ‚˜ λ³΄λ‚˜μš”? μ½”μ‹œκ΅­μ— λ”μš± μš°μšΈν•˜κ±°λ‚˜ 무기λ ₯ν•œ 건 햇살을 μΆ©λΆ„νžˆ 받지 λͺ»ν•΄μ„œ 일 μˆ˜λ„ μžˆμ–΄μš”. 맀일 단 15λΆ„μ˜ ν–‡μ‚΄λ§ŒμœΌλ‘œ 우리 λ‡Œμ—μ„œλŠ” μš°μšΈμ¦μ„ μ˜ˆλ°©ν•  수 μžˆμ„ 만큼의 μ„Έλ‘œν† λ‹Œμ΄ λΆ„λΉ„λ©λ‹ˆλ‹€. λ§Œμ•½ ν•˜λ£¨ λ™μ•ˆ λ‚΄κ°€ μ–Όλ§ˆλ‚˜

Sohee Kim 14 Oct 18, 2022
Bluetooth plugin for Flutter

Introduction FlutterBlue is a bluetooth plugin for Flutter, a new app SDK to help developers build modern multi-platform apps. Alpha version This libr

Paul DeMarco 2.2k Jan 5, 2023
A Flutter plugin for turning your device into a beacon.

Beacon Broadcast plugin for Flutter A Flutter plugin for turning your device into a beacon. Usage To use this plugin, add beacon_broadcast as a depend

Paulina Szklarska 75 Dec 14, 2022
Using Bluetooth plugin in Flutter (flutter_bluetooth_serial)

Flutter Bluetooth NOTE: This is the updated version of the app (using flutter_bluetooth_serial 0.2.2). This version has much fewer bugs and provides a

Souvik Biswas 179 Nov 22, 2022
null 5 Nov 21, 2022
Vernet - Network Analyzer and Monitoring Tool

Vernet Vernet - Network Analyzer and Monitoring Tool Features Shows Wi-Fi details Scans for devices(or hosts) on network Scans for open ports of targe

null 109 Dec 28, 2022
I have created app to connect printer with bluetooth. And I already fix library bugs

flutter_bluetooth_printer A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to ge

Bounphone KOSADA 1 May 11, 2022
Source code and instructions for do-it-yourself projects.

Ammolytics Projects Source code and instructions for do-it-yourself projects. Projects Open Trickler is a Do-It-Yourself, mobile-controlled powder tri

Ammolytics 39 Nov 15, 2022
Flutter library that handles BLE operations for multiple devices.

Flutter reactive BLE library Flutter library that handles BLE operations for multiple devices. Usage The reactive BLE lib supports the following: BLE

Philips Hue 473 Jan 4, 2023
FlutterBleLib - A library for all your Bluetooth Low Energy needs in Flutter.

FlutterBleLib A library for all your Bluetooth Low Energy needs in Flutter. Internally utilises Polidea's MultiPlatformBleAdapter, which runs on RxAnd

null 4 Jun 10, 2022
Bluetooth Low Energy library for Flutter with support for simulating peripherals

FlutterBleLib A library for all your Bluetooth Low Energy needs in Flutter. Internally utilises Polidea's MultiPlatformBleAdapter, which runs on RxAnd

intent 509 Jan 3, 2023
A Flutter Template to communicate with an esp32 over bluetooth

Flutter Esp32 Bluetooth Template Changes in android/ [1 if you take the code to an other project, 2 still nessesarely]: Change minSdkVersion from 16 t

0x4d/Martin Loretz 23 Dec 20, 2022
This flutter app will help you to connect to Bluetooth Devices (like, HC-05)

Flutter Bluetooth NOTE: This is the updated version of the app (using flutter_bluetooth_serial 0.2.2). This version has much fewer bugs and provides a

Riyad Al-Ali 1 Jun 5, 2022
Flutter basic implementation for Classical Bluetooth (only RFCOMM for now)

flutter_bluetooth_serial Flutter basic implementation for Classical Bluetooth (only RFCOMM for now). Features The first goal of this project, started

null 1 Nov 7, 2022
An app for small and medium organizations (SME) manager, with NFC-tag, e-tag and QR code features supported.

BK LAB Manager - an app for group management 1. Getting Started An app for small and medium organizations (SME) manager, with NFC-tag, e-tag and QR co

Andrew Ng 9 Dec 11, 2022
Flutter NFC reader plugin for iOS and Android

Flutter NFC Reader & Writer A new flutter plugin to help developers looking to use internal hardware inside iOS or Android devices for reading and wri

Matteo Crippa 321 Dec 30, 2022