NFC Share Example

The NFC Share example demonstrates the use of NFC stack and the AIW framework APIs for the communication between NFC enabled devices.


Click on the following link to download the example:

Click: browse to view the example code.


This example shows how two devices get paired using the NFC channel and share a file using the secondary bearer channel (for example, Bluetooth). Using the AIW framework, this example shows how to share a vCard or vCal from one device to other device.

Design and implementation

Class summary:

This example provides the following menu options:
  • Start Easy setup service

  • Start Sharing vCard

  • Start Sharing vCal

  • Stop Easy setup

  • Help

  • Exit

Once the two NFC-enabled devices are held close together and the Start Easy setup option is selected, both the devices get paired for the first time. The Start sharing vCard selection sends the default vCard. The Start Sharing vCal selection sends the default vCal to the other NFC device in proximity, which can be confirmed by the message notification. The sharing can be stopped by selecting the Stop Easy setup service option.

Building and configuring

You can build the example from your IDE or the command line.

If you use an IDE, import the file of the example into your IDE, and use the build command of the IDE.

If you use the command line, complete the following:
  1. Open a command prompt.

  2. Set the current directory to the source code directory of the example.

  3. Build the example with the following SBSv2 build commands:

    • qmake

    • sbs

The example builds executable called nfcshareexample.exe in the standard locations.

Running the example

After running the example application, the user is provided with menu options that are self-explanatory.

Note: The proximity of devices held together should be kept in mind to ensure proper communication because of the NFC antenna limitation. If the devices are not communicating properly, an asynchronous event failure notification is displayed.

Related concepts