Design Components for NFC
NFC functionality is implemented with the help of the following NFC-specific design components:
This action is used to start or stop the pushing and/or receiving of messages.
Pushing and/or receiving is started when the NFC Start action is triggered. The sequence of steps that the action sets in motion is as follows:
1.NFC must be enabled on the device. If NFC is not enabled, then triggering the Start action will cause a prompt to appear asking the user to enable NFC.
2.After ensuring that NFC is enabled, the MobileTogether Client app will be registered for NFC.
3.Immediately thereafter, NFC tag discovery is automatically started and NFC messages in NFC tags will be automatically received. Pushing can be started via an NFC Push action; it is not automatically started.
The NFC Stop action stops the pushing and receiving of all messages. To re-start the pushing and receiving of messages, trigger the Start action again.
See also Discovering and Reading NFC Tags.
The NFC Push action enables data to be transmitted from the device running the solution to another NFC-enabled device. Additionally, if Android Beam is enabled on two Android devices, then files can be beamed from one device to the other. The NFC Push action defines the message to push or the file to beam. When the action is triggered, the specified message or file is transmitted via NFC.
Note: NFC data-transmission is not supported on iOS device.
The \$MT_NFC tree is created as a page source in the design when an NFC Start action is defined. The tree is automatically populated when an NFC tag is discovered. The data from the NFC tag is stored in the nodes of the \$MT_NFC tree. For simulations, you can use an NFC sample file to see how data from the NFC tag is stored in the \$MT_NFC tree. (See the section NFC Sample Files for more information about NFC simulations.)
Two NFC-related events provide crucial functionality:
•OnPushNdefMessageCompleted specifies what action/s to carry out when the transmission of NFC data (via NFC Push) has been completed.
•OnNfcTagDiscovered specifies what (additional) action/s to carry out when an NFC tag is discovered. For example, when this event is triggered, an Update Node action can be used to update data-source trees with data from the discovered NFC tag.
The following NFC-related functions are available:
•mt-nfc-started: a Boolean test to check whether the solution has started NFC.
•mt-hexBinary-to-string: converts a hexBinary to a text string.
•mt-hexBinary-to-base64: converts a hexBinary to a Base64-encoded image.
•mt-string-to-hexBinary: converts a text string to a hexBinary string.
•mt-base64-to-hexBinary: converts a Base64-encoded image to a hexBinary string.
Since the payload of messages is transported in hexBinary format, the conversion functions enable data to be prepared for transport (that is, converted to to hexBinary) and converted from hexBinary to human-usable formats (text and images). For more detailed descriptions of these functions, see MobileTogether Extension Functions.
For simulations, you can create an NFC sample file and use this file to test whether data from NFC tags is being correctly imported into the \$MT_NFC tree. See the section NFC Sample Files for more information about NFC simulations.