Does a "Push To Beam" workaround exist? - android

I am currently trying to implement a basic NFC app on the Nexus 7.
I have been able to transmit an NDEF record (Web Url) using the Beam SDK but i'm stuck with the "Tap to beam" UI, like many others on here.
I am aware that there is no way to disable this screen or automatically press it, but, are the re any other possible workarounds?
For example, a colleague has just suggested something like putting the Nexus 7 in tag writer mode and then getting the other app into tag read mode.
Or am I correct in saying that NFC in Android can only be used to read/write NFC tags and also share items using beam?

The NFC chip continuously switches between Reader/Writer mode and peer-to-peer mode (and card emulation, if you have Google Wallet installed). In Reader/Writer mode, it can communicate with an NFC tag. Two devices in Reader/Writer mode cannot communicate with each other; that is what peer-to-peer mode was invented for. Peer-to-peer mode is what is used for Android Beam.
It is also not possible to use the card emulation mode on one device. First of all, an Android device will not detect the card emulation on another Android device (it prefers to do peer-to-peer). Secondly, your app would need special permission to access the Secure Element (that does the card emulation) from the OS. And, thirdly, even if you would manage to tackle these hurdles, there is still no way to write data to the Secure Element, as you don't have the necessary access control keys to do it.
So to answer your original question: there is no way to circumvent the Android Beam UI by switching to other NFC modes. Sorry.
UPDATE:
As of Android 4.4 Kitkat, apps have the possibility to emulate a card using so-called Host Card Emulation (HCE). For an app on another Android NFC device to communicate with such an emulated tag, it needs to use a new NFC Reader Mode (which disables Android Beam entirely to prevent it from getting in the way).

Related

Why Android & IOS11 cannot communicate via NFC

Currently using React Native and attempting to use react-native-nfc-ios and react-native-nfc so I can have cross-device communication between ios and Android. I'm finding that they cannot communicate, however I think it's due to a broader issue (as other existing apps also don't work).
If I download a NFC reader app on iPhone 7, and an NFC writer app on Android they cannot communicate. Why is this?
Instructions to Duplicate
Turn on NFC Reader on iPhone 7
Put some arbitrary data in NFC write mode on Android
Bringing devices together has no effect.
Not understanding the intricacies of NFC, it's hard for me as a casual programmer to understand what the actual problem is.
I understand that IOS11 on iPhone 7 (plus) supports NFC read, and generally speaking there are card emulation, peer to peer, and read write modes.
Should they not communicate? The iPhone is not able to pick up the
Android writer. Why is this?
How does card emulation (I assume to be Apple Pay), differ from a write mode?
The reason is because Apple's iOS 11 update only allows reading from NFC tags (writing is only permitted for Apple Pay). At the moment, their software does not share the same enjoyment afforded by Android phones which enable card emulation, peer-to-peer, and reader/writer NFC usage. So our only hope is to wait for a software update that will finally enable this existing feature for developers to use.

Use another Android device as NFC tag?

I am working on an app that will be deployed on a NFC enabled device. I am trying to enable authentication using NFC, so that a user can scan another NFC device such as phone to authenticate.
I went through the NFC documentation that Android has at http://developer.android.com/guide/topics/connectivity/nfc/nfc.html
I am not able to get my use case working.
Here is what I am trying to do:
Deploy app in Device A.
app on Device A will only try to scan for NFC when app is in foreground and is in Login Activity.
User can bring in Device B/NFC tag near Device A, Login Activity will authenticate the user.
I hope this is possible using NFC in Android. My search leads me to example that launches app when NFC is detected but that is not what i am after.
If you want to communicate beween two Android devices by using one as an emulated tag and the other as reader/writer (as opposed to transfering NDEF messages between two devices using Android Beam, which is based on NFC peer-to-peer mode), you could Android HCE (one one device) in combination with reader/writer mode (on the other device).
However, building a solution like this has some limitations. Regarding the emulating side, you have the following limitations and requirements:
Android HCE requires the emulating device to run Android 4.4 or later.
The emulating device needs to support host-based card emulation. Not all Android 4.4+ devices that have NFC also support HCE. For instance, all (most?) devices that contain NXP's PN544 NFC controller do not curently support HCE.
You can only emulate ISO/IEC 7816-4 appliction structures on top of ISO/IEC 14443-4. In case you want to emulate an NFC tag with NDEF data, this would be equivalent to an NFC Forum Type 4 tag. But you are, of course, not limited to emulating NDEF-style NFC tags.
However, an NFC tag (or rather a smartcard application) that is emulated like this imposes some requirements/limitations on the reader side as well:
Android's HCE capabilities run in parallel with its peer-to-peer mode capablities (regardless of whether the device has support for Android Beam enabled or not). As a consequence, other Android devices will detect Android HCE devices as peer-to-peer devices and, by default, communicate with them in peer-to-peer mode. Therefore, other Android devices will normally be unable to access an Android HCE emulated smartcard application.
Only starting with Android 4.4, you can disable peer-to-peer mode discovery by using the reader mode API. So you need Android 4.4+ on the reader side in order to access the emulated NFC tag.
This also prevents automatically starting an app on the second device upon discovery of the first device, so you can only use an Android HCE emulated smartcard application in combination with an activity that already runs in the foreground on the reading device.

Is it possible to transfer NFC data from one Android device to another without the 'Touch to Beam' screen?

I am trying to send NFC data from one Android device to another. I was able to do it successfully using the 'Touch to Beam' functionality. But I would like the data transfer to take place automatically as soon as both the devices are together.
I saw this question answered in StackOverflow multiple times. Unfortunately, while some say its not possible to send NFC data from one Android device to another this way, some others suggest to try "foreground-dispatching" (which the official documents say is now deprecated). I wasn't successful with "foreground dispatching" though I am not entirely sure if its due to my mistake. Almost all the questions were answered 1 year back, so I was wondering if Google changed something to achieve this. Both my devices are on Android 4.0 or later, but not 4.4.
When using NFC peer-to-peer communication (aka Android Beam) between two Android (4.0+) devices, there is no way to avoid the Beam UI. So it is not possible to transfer data without the "Touch to Beam".
Before Android Beam (effectively Android 2.3.3-2.3.7), this was possible through foreground NDEF push (which is now (a) deprecated and (b) on Android 4.0+ implemented through Beam). In that case NDEF messages where immediately transfered without the "Push to Beam" window.
Only starting with Android 4.4, there is the possibility to communicate between two Android devices over NFC without the Beam UI (actually without using Android Beam and peer-to-peer mode at all): If both devices are 4.4+, one device can use Android HCE to emulate a contactless smartcard and one device can use the reader-mode API (this only works with the reader-mode API introduced in 4.4, so both devices need to be 4.4+) to communicate with the emulated smartcard.

how does nfc reader(acr122) detect my phone?

I buy ACR122U SDK that has a acr122 reader,cd and cards and I try to test it. the reader detect the cards by changing its LED light from red to green but when I take my phone (NFC is turned on) near the reader,there is nothing happen.
How do I make the reader detect my phone? I have to install java card applet into my phone for letting my phone act as a contactless card?
Using the ACR122U NFC reader you have three options:
ACR122U in peer-to-peer mode: In peer-to-peer mode, you can communicate with an Android device using Android's built in Beam functionality. On the reader side you would need to implement the SNEP service (and the underlying LLCP + NFCIP-1 protocol stack). You can find examples, for instance, with ISMB-SNEP, NFC Tools and nfcpy.
ACR122U in card emulation mode: In card emulation mode the ACR122U can be used to emulate a tag/contactless smartcard that can be detected by an Android device just like any other NFC tag/contactless smartcard. You can find examples, for instance, with libnfc.
ACR122U in reader/writer mode: In reader/writer mode, the ACR122U can communicate with contactless smartcards. This goes into the direction of what takumar already posted in his answer. While you were stuck with the requirement of a secure element (which is typically difficult due to lack of access or even lack of an SE), with recent Android versions (specifically CyanogenMod 9.1+ or Android 4.4+), you have the option to use host card emulation (HCE) mode. See the Android documentation for how that works on Android 4.4 and later.
Your phone must be enabled for card emulation, not all are. Furthermore, you need to figure out where card emulation is routed to. This can be the SIM or some embedded secure element. Once that is done, you can think of deploying the application onto a test SIM (it is very unlikely that you'll ever get the keys to the embedded secure element). Working with an AOSP build of Android (for instance on the Nexus 5) helps because you can set the route. Test SIMs with test keys can be bought online I believe. Once you have one, you can use GPShell to install the application. Good luck.

Card emulation via software NFC

After reading a lot of questions, i decided to post this one. I read that stock version of android does not support API's for card emulation. Also, we cannot write custom applications to secure element embedded in nfc controllers due to keys managed by google/samsung.
I need to emulate a card (mifare or desfire etc). The option i can see is doing it via software. I have a ACR122U reader and i've tested that NFC P2P mode works fine with the Nexus-S that i have.
1) I came across a site that said that nexus s's NFC controller (pn532) can emulate a mifare 4k card. If this is true, can i write/read apdu commands to this emulated card? (Probably if i use a modded rom like cyanogenmod)
2) Can i write a android application that reads apdu commands sent from the reader and generate appropriate responses (if not fully, then upto some extent only). To do so, i searched that we need to patch nexus s with cynagenmod. Has someone tried emulating card via this method?
I see that this is possible since we have products from access control companies offering mobile applications via which one can open doors e.g. http://www.assaabloy.com/en/com/Products/seos-mobile-access/
Some facts that may be of help in your quest:
The NFC controller in the Nexus S (and Galaxy Nexus, Nexus 7 and quite a few other Android devices) is the PN544
Card emulation can be done either by the secure element connected to the NFC controller or by the host device (=Android device in this case). The Nexus S has a secure element that could be used for that (used in Google Wallet). Card emulation from the host device is not a feature of the PN544 NFC controller, although some claim that they have managed to get it working.
You can turn on card emulation by the secure element by rooting your device and following the instructions at https://stackoverflow.com/a/10506299/1202968 (haven't tried this with 4.x JB, but I assume that it still works).
Emulating a MIFARE Classic card can be done by the secure element in the Nexus S, but not by the host device. Emulating a DESFire card is not supported by the secure element in the Nexus S.
I have investigated a similar doorlock product that used card emulation itself to communicate to an NFC mobile device, while using card reader/writer mode to communicate to access control cards.
IMO, the 2 simplest options are: use P2P communication (Android Beam) or use card emulation in a reader device (if it supports it). All the other options require things like rooted devices and custom ROMs, which are not future-proof and have no possibility to be translated to a real product.
Card emulation via software is now available with Android 4.4. http://developer.android.com/guide/topics/connectivity/nfc/hce.html
2) Card emulation by software should definitely be possible, but not exposed in current Android APIs. You will have to dig deeper into the libnfc-nxp (and possibly below). This might be a difficult one though. This feature is offered on Inside Secure's chips, as shown in their OpenNFC reference implementation. The only question is whether it requires a CLF firmware change. If not, then you can hack it into a software image.
The caveats are, however, that you will lack the following features :
- security (an Android app is not as secure as a smartcard)
- fast and predictable response times (well, depends how you code it probably)
- card emulation running when phone is off
I believe SEOS is based on ISO14443-4 and not Mifare. This means you would need a secure element to run it.
1) Not too sure about this one, my guess is that this will still be hardware-based (e.g. depend on an embedded secure element such as NXP's SmartMX.
The other alternative is to start developing on a secure element. The most straightforward way would be to get some sample test SIMs with SWP/HCI support. There is a free dev kit called IzyNFC which you can use for the javacard, and GSMA and AFSCM technical documents for the Android application side.

Categories

Resources