Coder Social home page Coder Social logo

nfcim / flutter_nfc_kit Goto Github PK

View Code? Open in Web Editor NEW
195.0 11.0 114.0 456 KB

Flutter plugin to provide NFC functionality on Android and iOS, including reading metadata, read & write NDEF records, and transceive layer 3 & 4 data with NFC tags / cards

Home Page: https://pub.dev/packages/flutter_nfc_kit

License: MIT License

Kotlin 25.39% Swift 24.01% Objective-C 0.60% Dart 46.68% Ruby 2.02% HTML 1.30%
flutter flutter-plugin nfc nfc-tag android ios kotlin swift ndef

flutter_nfc_kit's Introduction

Flutter NFC Kit

pub version Build Example App

Yet another plugin to provide NFC functionality on Android, iOS and browsers (by WebUSB, see below).

This plugin's functionalities include:

  • read metadata and read & write NDEF records of tags / cards complying with:
    • ISO 14443 Type A & Type B (NFC-A / NFC-B / MIFARE Classic / MIFARE Plus / MIFARE Ultralight / MIFARE DESFire)
    • ISO 18092 (NFC-F / FeliCa)
    • ISO 15963 (NFC-V)
  • R/W block / page / sector level data of tags complying with:
    • MIFARE Classic / Ultralight (Android only)
    • ISO 15693 (iOS only)
  • transceive raw commands with tags / cards complying with:
    • ISO 7816 Smart Cards (layer 4, in APDUs)
    • other device-supported technologies (layer 3, in raw commands, see documentation for platform-specific supportability)

Note that due to API limitations, not all operations are supported on all platforms. You are welcome to submit PRs to add support for any standard-specific operations.

This library uses ndef for NDEF record encoding & decoding.

Dependency issue of js package

Since v3.5.0, flutter_nfc_kit depends on js: ^0.7.1. This might lead to a conflict with other packages that depend on js: ^0.6.4. If you do not use this plugin in a web environment, you can safely add the following to your pubspec.yaml to resolve the conflict:

dependency_overrides:
  js: "^0.6.4"

Setup

Thank nfc_manager plugin for these instructions.

Android

iOS

Web

The web version of this plugin does not actually support NFC in browsers, but uses a specific WebUSB protocol, so that Flutter programs can communicate with dual-interface (NFC / USB) devices in a platform-independent way.

Make sure you understand the statement above and the protocol before using this plugin.

Usage

We provide simple code example and a example application.

Refer to the documentation for more information.

Error codes

We use error codes with similar meaning as HTTP status code. Brief explanation and error cause in string (if available) will also be returned when an error occurs.

flutter_nfc_kit's People

Contributors

akashark avatar brayflex avatar carlblock avatar dangfan avatar engeen avatar harry-chen avatar jiegec avatar knthm avatar larssn avatar luckycreationsindia avatar rostopira avatar shiwano avatar smlu avatar thuzxj avatar timnew avatar z4yx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_nfc_kit's Issues

PlatformException(406, No tag polled, null)

[log] PlatformException(406, No tag polled, null)
[log] #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)

请问这是这么回事?

iOS iso7816 transceive 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_kit

var tag = await FlutterNfcKit.poll(timeout: Duration(seconds: 10), iosMultipleTagMessage: "Multiple tags found!", iosAlertMessage: "Scan your tag");
    print(tag.type);

    if (tag.type == NFCTagType.iso7816) {
      var result = await FlutterNfcKit.transceive(Uint8List.fromList([0x00, 0xA4, 0x04, 0x00, 0x08, 0x50, 0x41, 0x59, 0x2E, 0x54, 0x49, 0x43, 0x4C, 0x00]));
      print(result);
    }

flutter_nfc_kit Response

flutter: FlutterNfcKit poll
flutter: NFCTagType.iso7816
flutter: [106, 130]
[CoreNFC] 00000002 8001c870 -[NFCTagReaderSession setAlertMessage:]:90  (null)
[CoreNFC] 00000002 8001c870 -[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. 🙏

iOS Background Reading

Is it possible to do iOS Background reading?

Meaning reading a tag without the annoying pop-up of the iPhone.

popup waiting to scan on android

hi,

first i want to say thank you for your times to create this plugin.

is it possible to have the same alert popup waiting to scan on android phone?

big thanks

Feature request : tag id as byte array

Hi,

Would it be possible to access a tag id as a byte array ?

The string given from the library is not consistent between Android and iOS, one using little endians, the other using big endians.
It would allow reversing the byte array depending on the platform instead of handling strings.

Read memory

Hello, is it possible to read the memory of a card directly (not as a NDEF tag)?
The point of reading the data directly, is to code the memory to avoid the annoying android NDEF tag dialog popup.
The app: NFC Tools, has this options, and I need it :)

iso7816 support in android

I am not an expert in NFC, but I want to ask can I connect android nfc card with specifc AID with APDU (iso7816)
i can see that ios have aid field in info.plist
Is it supported in Android without specifying it?

Writing WiFi config to NFC

I want to write a WiFi config to NFC. Does your latest version support this functionality? If not, could you suggest me an idea to write WiFi config to NFC via flutter_nfc_kit itself.

Thank you

can't read this card AID : A0000000030000 on ios

in ios i can't read this tag card but working on android

{"type":"iso7816","standard":"ISO 14443-4 (Type A)","id":"B552C648","atqa":"0400","sak":"20","historicalBytes":"80318066B1840C016E0183009000","hiLayerResponse":"","protocolInfo":"","applicationData":"","manufacturer":"","systemCode":"","dsfId":"","ndefAvailable":false,"ndefType":"","ndefCapacity":0,"ndefWritable":false,"ndefCanMakeReadOnly":false}

AID : A000000003000000

CocoaPods could not find compatible versions for pod "flutter_nfc_kit"

Getting the following error when "pod install" is being run during my builds.
My minimum deployment setting in Xcode is set to 14.1

[!] CocoaPods could not find compatible versions for pod "flutter_nfc_kit":
      In Podfile:
        flutter_nfc_kit (from `.symlinks/plugins/flutter_nfc_kit/ios`)

    Specs satisfying the `flutter_nfc_kit (from `.symlinks/plugins/flutter_nfc_kit/ios`)` dependency were found, but they required a higher minimum deployment target.

Crash when using iPhone 6

Hi,

thank you for this great plug-in!

I have an issue when using this plug-in on an iPhone 6 without NFC support. I removed any call to the plug-in in this case, but I get following error during startup of my app:

dyld: Library not loaded: /usr/lib/swift/libswiftCoreNFC.dylib
Referenced from: /private/var/containers/Bundle/Application/5A8733CD-0DD4-4356-9E37-C4567C2034A/Runner.app/Frameworks/flutter_nfc_kit.framework/flutter_nfc_kit
Reason: image not found

How to avoid this error?

SDK Version 31 leads to an Error

Error when using targetSDKVersion 31:

E/MethodChannel#flutter_nfc_kit(30191): Failed to handle method call
E/MethodChannel#flutter_nfc_kit(30191): java.lang.IllegalArgumentException: com.xxxx.xxxxxx: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/MethodChannel#flutter_nfc_kit(30191): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/MethodChannel#flutter_nfc_kit(30191): at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/MethodChannel#flutter_nfc_kit(30191): at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
E/MethodChannel#flutter_nfc_kit(30191): at android.app.PendingIntent.getActivity(PendingIntent.java:444)
E/MethodChannel#flutter_nfc_kit(30191): at android.app.PendingIntent.getActivity(PendingIntent.java:408)
E/MethodChannel#flutter_nfc_kit(30191): at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin.pollTag(FlutterNfcKitPlugin.kt:303)
E/MethodChannel#flutter_nfc_kit(30191): at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin.handleMethodCall(FlutterNfcKitPlugin.kt:88)
E/MethodChannel#flutter_nfc_kit(30191): at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin.onMethodCall(FlutterNfcKitPlugin.kt:62)
E/MethodChannel#flutter_nfc_kit(30191): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter_nfc_kit(30191): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/MethodChannel#flutter_nfc_kit(30191): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/MethodChannel#flutter_nfc_kit(30191): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter_nfc_kit(30191): at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#flutter_nfc_kit(30191): at android.os.Looper.loopOnce(Looper.java:161)
E/MethodChannel#flutter_nfc_kit(30191): at android.os.Looper.loop(Looper.java:288)
E/MethodChannel#flutter_nfc_kit(30191): at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MethodChannel#flutter_nfc_kit(30191): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_nfc_kit(30191): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MethodChannel#flutter_nfc_kit(30191): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

NFC Tag not reading and throwing weird exception

I keep getting this error in my Firebase Crashlytics console for Android users. It's not letting them scan their NFC tags properly.

Does someone know why this is happening?

This seems to happen on some phones. The model is not the issue because it works for Samsung S1 model and also throws this exception for other users with the same device...

Exception:

PlatformException(error, context cannot be null, null, java.lang.IllegalArgumentException: context cannot be null
	at android.nfc.NfcAdapter.getDefaultAdapter(NfcAdapter.java:871)
	at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin.handleMethodCall(FlutterNfcKitPlugin.kt:63)
	at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin.onMethodCall(FlutterNfcKitPlugin.kt:58)
	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:336)
	at android.os.Looper.loop(Looper.java:197)
	at android.app.ActivityThread.main(ActivityThread.java:8167)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
). Error thrown NFC Unknown Error.
       at StandardMethodCodec.decodeEnvelope(message_codecs.dart:581)
       at MethodChannel._invokeMethod(platform_channel.dart:158)
       at FlutterNfcKit.poll(flutter_nfc_kit.dart:204)

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 2.0.3, on macOS 11.4 20F71 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.63.2)
[✓] Connected device (2 available)

• No issues found!

Flutter version: v.2.0.3

Package version: v2.2.1

Support make the NDEF tag readonly

I searched the API list but could not find any way to make the Ndef tag readonly.

Would be nice to support following code:

if (await FlutterNfcKit.isWritable()) {
  await FlutterNfcKit.makeReadOnly();
}

For Android Ndef.isWritable, Nedf.canMakeReadOnly and Nedf.makeReadOnly does the trick.

For iOS, NFCNDEFTag.queryNEDFStatus and NFCNDEFTag.writeLock` does the trick.

I'm a bit busy for now, might be able to provide PR later.

Password Protection

Any consideration for functionality creating password encryption with NFC tags? I have NTAG213 and I need to allow my users to protect their tag so that nobody else can overwrite their content.

Not needed entitlements

Hello,

I found an issue starting since v1.2.0.

Since that time the iOS version tries to detect different types of NFC tags:

NFCTagReaderSession(pollingOption: [.iso14443, .iso15693, .iso18092], delegate: self)

before it only used

NFCTagReaderSession(pollingOption: [.iso14443], delegate: self)

As i only use iso14443 tags in a security sensitive application, it is for me a security issue to add entitlements for unused tag technologies.

Would it be possible to add the tag type to FlutterNfcKit.poll ?

Thank you very much!

Failed to build iOS app

Xcode: 11.6
Flutter: 1.17.5
Flutter_nfc_kit: 2.0.0

When launching sample app, build fails:

Xcode's output:
↳
    Command CompileSwift failed with a nonzero exit code
    Command CompileSwift failed with a nonzero exit code
    /Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nfc_kit-2.0.0/ios/Classes/SwiftFlutterNfcKitPlugin.swift:251:41: error: value of optional type 'NFCTypeNameFormat?' must be unwrapped to a value of type 'NFCTypeNameFormat'
                                    format: format,
                                            ^
    /Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nfc_kit-2.0.0/ios/Classes/SwiftFlutterNfcKitPlugin.swift:251:41: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                                    format: format,
                                            ^
                                                   ?? <#default value#>
    /Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nfc_kit-2.0.0/ios/Classes/SwiftFlutterNfcKitPlugin.swift:251:41: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                                    format: format,
                                            ^
                                                  !
    /Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nfc_kit-2.0.0/ios/Classes/SwiftFlutterNfcKitPlugin.swift:252:68: error: cannot convert value of type 'Any?' to expected argument type 'String'
                                    type: dataWithHexString(hex: record["type"]),
                                                                       ^
                                                                                as! String
    /Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nfc_kit-2.0.0/ios/Classes/SwiftFlutterNfcKitPlugin.swift:253:74: error: cannot convert value of type 'Any?' to expected argument type 'String'
                                    identifier: dataWithHexString(hex: record["identifier"]),
                                                                             ^
                                                                                            as! String
    /Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_nfc_kit-2.0.0/ios/Classes/SwiftFlutterNfcKitPlugin.swift:254:71: error: cannot convert value of type 'Any?' to expected argument type 'String'
                                    payload: dataWithHexString(hex: record["payload"])
                                                                          ^
                                                                                      as! String
    Command CompileSwift failed with a nonzero exit code
    Command CompileSwift failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Could not build the precompiled application for the device.

Error launching application on iPhone.

Error running on iOS target

I've set up the entitlements as listed in the readme. But when try to run on iOS I get the following Pod error

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
lib/main.dart:1
CocoaPods' output:
↳
      Preparing
    Analyzing dependencies
    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
    Finding Podfile changes
      A flutter_nfc_kit
      - Flutter
      - fluttertoast
      - image_picker
      - path_provider
      - share
      - shared_preferences
      - uni_links
      - url_launcher
    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `flutter_nfc_kit` from `.symlinks/plugins/flutter_nfc_kit/ios`
    -> Fetching podspec for `fluttertoast` from `.symlinks/plugins/fluttertoast/ios`
    -> Fetching podspec for `image_picker` from `.symlinks/plugins/image_picker/ios`
    -> Fetching podspec for `path_provider` from `.symlinks/plugins/path_provider/ios`
    -> Fetching podspec for `share` from `.symlinks/plugins/share/ios`
    -> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
    -> Fetching podspec for `uni_links` from `.symlinks/plugins/uni_links/ios`
    -> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`
    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
    [!] CocoaPods could not find compatible versions for pod "flutter_nfc_kit":
      In Podfile:
        flutter_nfc_kit (from `.symlinks/plugins/flutter_nfc_kit/ios`)
    Specs satisfying the `flutter_nfc_kit (from `.symlinks/plugins/flutter_nfc_kit/ios`)` dependency were found, but they required a higher minimum deployment target.
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:254:in `process_topmost_state'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/resolver.rb:94:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:23:in `load'
    /usr/local/bin/pod:23:in `<main>'
Error running pod install
Error launching application on iPhone 11 Pro Max.
Exited (sigterm)

Reader Mode Flags (FLAG_READER_NO_PLATFORM_SOUNDS) and (FLAG_READER_SKIP_NDEF_CHECK) are misconfigured

Currently, in the library code:

if (!androidCheckNDEF) technologies |= 0x100;
if (!androidPlatformSound) technologies |= 0x80;

but, according to the android documentation:

FLAG_READER_NO_PLATFORM_SOUNDS

Setting this flag allows the caller to prevent the platform from playing sounds when it discovers a tag.

Constant Value: 256 (0x00000100)
----------------------------------------------------------------------------------------
FLAG_READER_SKIP_NDEF_CHECK

Setting this flag allows the caller to prevent the platform from performing an NDEF check on the tags it finds.

Constant Value: 128 (0x00000080) 

I think you misconfigured the flags so that the checkNDEF flag actually manipulates the androidPlatformSound, and the platformSound actually manipulates the checkNDEF flag. I verified this issue by setting the platform sound to false and therefore, being unable to read NDEF tags.

Also, thanks for this library!

error transceive on ios NSLocalizedDescription=Missing required entitlement, on android working

{"type":"iso7816","standard":"ISO 14443-4 (Type A)","id":"AF5AB23C","atqa":null,"sak":null,"historicalBytes":"","hiLayerResponse":null,"protocolInfo":null,"applicationData":null,"manufacturer":null,"systemCode":null,"dsfId":null,"ndefAvailable":false,"ndefType":"","ndefCapacity":0,"ndefWritable":false,"ndefCanMakeReadOnly":false}
[CoreNFC] 00000002 83905200 -[NFCTagReaderSession transceive:tagUpdate:error:]:771 Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement}

i've added
com.apple.developer.nfc.readersession.formats

NDEF
TAG

in Runner.entitlements

NFCTag class isn't null-safe

I've tried to read tag with this library on iOS, got

Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast
#0      _$NFCTagFromJson (package:flutter_nfc_kit/flutter_nfc_kit.g.dart:14:18)
#1      new NFCTag.fromJson (package:flutter_nfc_kit/flutter_nfc_kit.dart:108:57)
#2      FlutterNfcKit.poll (package:flutter_nfc_kit/flutter_nfc_kit.dart:215:19)
<asynchronous suspension>
#3      NfcPageState.readFromTag (package:profit_tracker/nfc_page.dart:29:17)
<asynchronous suspension>

NFCTag has every field as non-null, however even docs say the opposite:

  /// ATQA (Type A only, Android only)
  final String atqa;

Exception when TextRecord.language is null

Thank you for the great package!

I noticed that in TextRecord constructor language is not marked as required and doesn't have any default value.
So if user doesn't set it null will be the value.
But null causes exception in TextRecord.payload method on utf8.encode(language).

For example:

final newRec = ndef.TextRecord(text: actionIdRec);
await FlutterNfcKit.writeNDEFRecords([newRec]);

this will cause exception.

Same will be if text itself is null. Though it is rare use case I suppose.
So text and language can be marked as @required or checked if it is null before usage.

NDEF not supported on current tag

您好,我的卡是mifare classic,我用您例子里面的代码读取数据,就直接报错了
if (tag.type == NFCTagType.mifare_classic) {
//print(tag.toJson());
var ndefRecords = await FlutterNfcKit.readNDEFRecords();
//print(jsonEncode(ndefRecords).toString());
var ndefString = ndefRecords.map((r) => r.toString()).reduce((value, element) => value + "\n" + element);
//print(ndefString);
}

[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(405, NDEF not supported on current tag, null, null)
E/flutter (25307): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:582
E/flutter (25307): #1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:159
E/flutter (25307):
E/flutter (25307): #2 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:332
E/flutter (25307): #3 FlutterNfcKit.readNDEFRawRecords
package:flutter_nfc_kit/flutter_nfc_kit.dart:249
E/flutter (25307): #4 FlutterNfcKit.readNDEFRecords
package:flutter_nfc_kit/flutter_nfc_kit.dart:236

Read credit card number

I'm using my smartphone to read the nfc cheap of my credit card, the read is SUCCESS but i can't see the card number, cvv and date

read Error Toast on Android 10

Hello again,

I have encountered another issue while using NFC Reader mode in your plugin on Android 10. There is sometimes a toast shown with
"NFC read error. Try again." Despite the reader Mode API polled the TAG successfully.

image

This toast is generated by the Android NFC service itself when checking for NDEF Tags.
see here in Android Documentation

Currently I'm not using any NDEF Tags in my app so I would like to skip the NDEF Check which can be done by setting the reader Flag:
FLAG_READER_SKIP_NDEF_CHECK in reader Mode see here .

Could you please extend your plugin with an option to set this flag?

Support EventChannel(s)

Recommend supporting Streams through EventChannel, as it makes some operations easier (like having a listener running in the background).

Then it would be possible to having a simple API like:

var streamSub = FlutterNfcKit.tags.listen((tag) {
   print(tag);
});

Just a suggestion. Sadly I have no time to do a PR.

Not showing any credit card details

I have version 3.0.2 I am trying to ready credit card data but it's showing Transceive Result null. I have tried multiple cards but it's not showing any card information just display NFC details etc. Is this plugin to show card info or not? I confirm with apps that are correctly showing my card data through NFC but this is showing null on all my cards.

App crash when run on ios 14.1

Hi Sir,
I followed the setup in pub.dev for ios(add to Info.plist file), but the app crash when going to the widget using FlutterNfcKit.poll or FlutterNfcKit.transceive, then NFCAvailability.available work ok only. I don't know how to fix this issue, many thank if you can help me resolve it. I using nfc ISO7816 for NXP smart card.
Thanks,
The Anh

how i convert transceive result to json ?

i get code like 6032986093509312241101209111045400910301060000000000037457AF740752695AF81BC87B52F92B96D909507384B6AEB050C30011012003F63D0DFFFF9000.

how i convert to json ?

Android default NFC reader gets triggered

This issue only occurs on Android whenever I try to scan NFC tag using my own app where it triggers the default NFC reader of the phone.

Is there a way to prevent it and read only from the app library?

Ios 14.2(iPhone XR) Dialog NFC scan don't show

In my widget, I call:
print('BEFORE FlutterNfcKit.poll');
var tag = await FlutterNfcKit.poll(
// timeout: Duration(seconds: 600),
iosMultipleTagMessage: "Multiple tags found!",
iosAlertMessage: "Scan your tag");

print(jsonEncode(tag));
print('AFTER FlutterNfcKit.poll');

But dialog NFC scan don't show in iPhone and debug stop at line await FlutterNfcKit.poll(...
Please help me check it

After writing Android tries to read tag immediately

  • Use example app
  • Write to some tag
  • If you hold it still it can trigger the system reader and if URL it will open the browser

After a write there should be a way to prevent triggering this

Tested with Samsung S8

androidx.core:core-ktx:1.7 fails release build

The library androidx.core:core-ktx:1.7 now causes resource linking issue and seems no easy fix for now except downgrade.

* What went wrong:
Execution failed for task ':flutter_nfc_kit:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR:/Users/timnew/.gradle/caches/transforms-3/fa2e903d500609c2badd44e01c2b21b1/transformed/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

Check more:

Change Reader Flags for Android Reader Mode

Hi,

thank you for the great NFC plugin.

I would like to turn off default android sounds while reading a NFC tag. After some research I found out that this can be done by setting the flag FLAG_READER_NO_PLATFORM_SOUNDS (see here), which is currently not set in your plugin. Is there a way to change the Reader flags in your plugin? It would be great to be able to do this with your plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.