How to exchange data and files between two devices by NFC using Flutter? - flutter

I am a flutter developer, I want to make an application to exchange messages and files by using NFC technique
I used nfc_in_flutter plugin for reading and writing NFC tags but I don't know how to send and receive data and files between devices by using NFC in flutter.
Could any one help me, please?

Generally you don't try and send data between 2 devices using NFC, there is a standard for it, but most devices don't support it (it has never been supported on iOS and Android has dropped support for it as it was unreliable)
Use Bluetooth or Wifi Direct instead.
Update:
If you have to use NFC then the nfc_in_flutter plugin is no use, you are going to have to call native code for each platform yourself / write your own plugin.
And for 2 iOS devices, then forget it, just not possible because of what the OS supports.
When one device is an Android there is a complicated method that some people have had some success with but it still has it's issue.
The Android device does Host Card Emulation (HCE) and pretends to be a really Type 4 NFC tag, then other devices can read/write to it as if it were a real Tag which both iOS and Android Support. BUT on older Android devices then the deprecated Android Beam might get in the way and you would need to use enableReaderMode to do the read/write on Android.
You will need to put in a lot of error handle in the read/write App as NFC comms is very slow and very prone to loosing the connection, so it would have to handle loosing the connection and restarting where it last successful read from/written to.
All these problems make this extremely difficult to achieve a workable solution and was the main reason Google removed Android Beam for Android to Android sharing (which does use a NFC peer to peer protocol)

Related

Anyone knows whay Flutter_beacon Randomly stops working or may suggest another plugin

I'm using flutter_beacon plugin, It was working awesome on android. Ranging the close devices and getting the information that the beacon was broadcasting. But now, It suddenly stops reading the information, as the beacon would have disappeared. Any suggestions how to fix this??
The library im using is this one:
https://pub.dev/packages/flutter_beacon
There are lots of reasons an Android device might fail to detect beacons. The flutter_beacon plug-in you mention is built in top of the Android Beacon Library, which is the most widely used beacon library for Android.
You may want to try out that library’s reference app for Android (or the BeaconScope app for Android which is also built upon that same library.) If you find that these native apps have a similar problem on your device, then the problem may be device-specific.
The Android Beacon Library has a troubleshooting page that may be useful to you. Many of the same checks will be applicable to using the flutter_beacon plug-in.

Is it possible to make mobile p2p app without a server?

What I want is to make a web/mobile app (I've chosen Flutter) that acts both as a host and as a client, so multiple instances of this app can share data without actual back-end (let's say the addresses of the devices are hardcoded into the app for the simplicity).
I can't use Firebase or Backendless, my app has to be the only host.
I've looked into socket.io, websockets, WebRTC and didn't find a solution.
So, is it even possible? With or without Flutter.
It is in theory possible, if you are planning to only use android you can use this library Flutter p2p which use wifi-direct (Android documentation) to discover devices and connect to them. It has some problems with newer environments but there is lots of forks from the git project that you can import. I've read that it should be possible to allow devices that doesn't support wifi-direct to connect if you create a group so maybe it could work for iOS if there is a hosting android device.

NFC Write and read tags between Android & iOs

Need to have some information about NFC reading and writing tags, with phonegap in IONIC
I would like to make an app with shared data between 2 mobiles, I want to know if it's possible to read and write it between two phones using a different OS like Android and iOs.
Do you know if it's possible or if it will have any limitation with this use?
Without having a real NFC Card to acts as intermediary between devices, due to lacking NFC support in iOS
iOS <=> iOS is impossible
iOS <=> Android is complicated
Android <=> Android is complicated
iOS does not support NFC Peer to Peer, Android does support NFC Peer to Peer before Android 10 but it is now deprecated.
This leaves Host Card Emulation where one device pretends to be a real card, iOS does not support this (Only Apple themselves can do this), Android Supports this but it is not the simplest thing to do natively and probably does not have a module to help.
Better to use Bluetooth or Wifi Direct.

Flutter: Is it possible to make a P2P connection with nfc_in_flutter package?

I would like to send a message from an Android device to an IOS device using NFC.
I found multiple NFC packages and tried out example app from nfc_in_flutter but was not able to send a message between 2 phones.
Do they only support reading and writing to NFC-Tags or am I missing something?
iOS does not support Peer to Peer NFC even natively and Android has deprecated support for it in Android 10 (Android Beam).
So you are not missing something, iOS lags behind Android and only in iOS 13 supports reading/writing where as Android has supported reading/writing and Host Card Emulation for a long time.
Better to use Bluetooth or Wifi Direct

Ionic BLE Connection Issues

I'm using the Ionic Native BLE plugin to scan and connect to bluetooth devices. I'm able to get the plugin to list available devices, but I'm unable to get it to show already paired devices. This is the plugin I'm using:
https://ionicframework.com/docs/native/ble/
After searching through the documentation and finding examples, I've come to the conclusion that using this plugin to list already paired devices is just not possible. Is this the correct conclusion?
If so, do you know of any other plugins I could use to facilitate the looking up of paired bluetooth devices? I'm using Ionic 3.
We have been working on a simple BLE button and had the same issues. The only way we found out how to do this was to disconnect the button on app close (which the latest BLE version seems to do). We save the device ID (localStorage) when a user connects a device and then when the app starts up again the user has to wake up the device and the app starts scanning on startup. If the saved device id is the the id as your locally saved id it connects automatically.
If you, or anyone, wants to try other plugin, you can also try this: https://ionicframework.com/docs/v3/native/bluetoothle/
I first started using the same plugin that you use. After I encountered some difficult issues due to the strange operations of some bluetooth devices, I tried the second plugin and I found it to be better. That was three years ago and I can't say how the other plugin has improved in the present. One thing I like with the bluetoothle plugin is that it has many methods available and that gives more control to the bluetooth operations. You can look at these methods in its repo:
https://github.com/randdusing/cordova-plugin-bluetoothle