Recently at the WIMA conference in Monaco, Rovio revealed the new Angry Birds Magic together with Nokia. It unlocks additional levels when you touch the phones of friends, or if you find special promotional tags. This is done using Near Field Communication (NFC) technology.
How can you implement such exciting features yourself?
During the very same conference, Nokia hosted an NFC workshop where we were guiding through our new NFC developer offering. After an introduction by Sixten “Sigge” Sandstrom, Riikka Kivela explained the NFC architecture in Symbian devices. At the end of the event, Tuukka Ahoniemi from Digia quickly dissected their ShopWizer NFC app, followed by Jure Sustersic talking about business opportunities with NFC and Nokia.
During the main two hour tech session in the middle, I had the opportunity to first briefly introduce the large audience to Nokia’s NFC developer offering. After the environment setup with the latest Qt SDK 1.1 and Qt Mobility 1.2 Beta, you’re ready to code. At the moment, a Nokia C7 updated with a pre-release Symbian Anna is needed to test apps. This firmware version will be released soon, but is not publically available yet. Once you get the new version on your existing C7, the operating system’s backend for Qt’s NFC APIs are instantly available!
After those preparations were done, we went right into coding the first NFC app. Instead of starting totally from scratch, we took the Corkboards example from the Qt SDK and extended it with NFC functionality. The original app has several dynamic notes pinned to different corkboards; you can easily switch between boards by swipe gestures.
After following the step-by-step instructions of the NFC workshop materials, a new note instantly appears when touching an NDEF formatted NFC tag – the contents of the message are shown on the screen (URI and Text NDEF records are parsed). If you then press the little NFC flag glued to each note, the note’s current contents are written back to the tag. You can download a slightly extended version of the solution from Forum Nokia Projects.
Thanks to the separation of the NFC handling engine in C++ and the UI written with Qt Quick, the engine itself can simply be plugged into every other project to augment it with NFC. After the workshop, I saw the NFC engine working in an existing Cover Flow-like image browsing app; this was done in a matter of minutes without any modifications to the engine itself.
The second example was the NFC Chat. Simply by touching two phones, you can send chat messages back and forth. On the tech side, this is all handled by NFC, where two devices communicate using LLCP. Touching is enough to establish the connection between the app running on both phones.
This time, we created a new app from scratch – which can be done in a matter of minutes when using the Qt Quick Designer. The NFC target discovery is then very similar to the previous example – only that we’re this time setting up sockets to communicate to another device, instead of reading messages from a tag. A server socket is then used to send messages to the other device; the client socket receives our UTF-8 formatted text messages.
The workshop materials are now all online for you to enjoy:
- Workshop slides: Qt Quick basics, NFC and NDEF messages basics, step-by-step walkthrough for both code both examples
- NFC Corkboard example
- NFC Chat example
To find out more about developing NFC apps, also take a look at the new NFC Wiki page. More event coverage – including an interview with Mark Selby about Nokia’s NFC plans – check out Nokia Conversations.