×
Namespaces

Variants
Actions
(Difference between revisions)

Developing NFC Applications

From Nokia Developer Wiki
Jump to: navigation, search
jure.sustersic@nokia.com (Talk | contribs)
(Jure.sustersic@nokia.com -)
jure.sustersic@nokia.com (Talk | contribs)
m (Jure.sustersic@nokia.com - - UI design considerations)
Line 55: Line 55:
 
In this case the application should restrict its installation to NFC capable phones only and/or query whether the NFC functionality is available at runtime.
 
In this case the application should restrict its installation to NFC capable phones only and/or query whether the NFC functionality is available at runtime.
 
Where NFC is available as a firmware upgrade (such as on the Nokia C7 phone through the Symbian Anna update), the application should ideally alert the user to upgrade the firmware with message "Please update your phone firmware to run this application" and then exit.  
 
Where NFC is available as a firmware upgrade (such as on the Nokia C7 phone through the Symbian Anna update), the application should ideally alert the user to upgrade the firmware with message "Please update your phone firmware to run this application" and then exit.  
<gallery>
+
 
File:Upgrade_your_firmware.jpg
+
[[File:upgrade_your_firmware.jpg]]
</gallery>
+
 
   
 
   
 
====NFC enhanced application====
 
====NFC enhanced application====
Line 74: Line 73:
 
A model user experience flow is demonstrated by the [ NFC share application]. In this application as the application starts it checks the status of the NFC radio and informs the user if the radio is off with the message "NFC is not active. Please activate NFC from Connectivity settings before using this application".
 
A model user experience flow is demonstrated by the [ NFC share application]. In this application as the application starts it checks the status of the NFC radio and informs the user if the radio is off with the message "NFC is not active. Please activate NFC from Connectivity settings before using this application".
 
   
 
   
<gallery>
+
[[File:turn_nfc_on.jpg]]
File:turn_nfc_on.jpg
+
</gallery>
+
 
   
 
   
 
===Implementation===
 
===Implementation===
Line 93: Line 90:
 
*[http://projects.developer.nokia.com/NfcSettingsApplication NfcSettings application(Qt/Symbian)] - This project uses the NFC feature and NFC radio logic from the[http://projects.developer.nokia.com/mobilenfcapp Mobile NFC app] template andapplies it to a very simple application that shows the availability of NFC andradio status on the phone using a simple QML UI.
 
*[http://projects.developer.nokia.com/NfcSettingsApplication NfcSettings application(Qt/Symbian)] - This project uses the NFC feature and NFC radio logic from the[http://projects.developer.nokia.com/mobilenfcapp Mobile NFC app] template andapplies it to a very simple application that shows the availability of NFC andradio status on the phone using a simple QML UI.
 
*[http://projects.developer.nokia.com/nfcinteractor NFCinteractor (Java ME)] -This project demonstrates how to handle the NFC dependency in a Java Midlet. Itqueries the ''microedition.contactless.version'' system property value for thesupported JSR-257 version. If the API is supported on the phone, the propertyreturns 1.0.
 
*[http://projects.developer.nokia.com/nfcinteractor NFCinteractor (Java ME)] -This project demonstrates how to handle the NFC dependency in a Java Midlet. Itqueries the ''microedition.contactless.version'' system property value for thesupported JSR-257 version. If the API is supported on the phone, the propertyreturns 1.0.
+
 
+
 
== Testing==
 
== Testing==
 
   
 
   

Revision as of 15:29, 19 August 2011

This article explains how to create NFC applications for the latest NFC equipped Symbian phones using Qt or Java technology. The article provides details on the UI considerations in NFC application design and the requirements for NFC applications to be distributed through Nokia Store. A pointer is provided to a project that enables NFC features for Symbian WRT widgets.

Contents

Introduction

You can create applications that leverage NFC technology using APIs provided in Qt, Java™ ME, and Symbian C++. Of these options, using Qt is the recommended approach as it’s the core development framework for Symbian and is available for MeeGo powered phones as well.

Qt based development

You create NFC enabled applications using the Qt Mobility 1.2 Connectivity API. The advantage of this approach is that you are working with the productive Qt cross-platform API, so you can code once for an app that will run on Symbian and MeeGo phones.

To get started you need an NFC enabled phone and the Qt SDK 1.1 plus:

You can find example apps and code in the Qt Mobility 1.2 beta for Symbian add on package. The package enables development with the Symbian C++ NFC API also.

Further example apps are the NFC Corkboard (demonstrates NDEF reading and writing) and NFC Chat (LLCP peer-to-peer communication). In addition, you can download a step-by-step walkthrough tutorial that explains how to code these apps plus the basic Qt concepts required for understanding the interaction.

Java ME based development

You can make use of the NFC features in Symbian phones using the Contactless Communication API (JSR-257) and Nokia Extensions to JSR-257. This may be the most convenient approach if you have developed NFC applications for Series 40 phones (such as the Nokia 6131 NFC and Nokia 6212 classic). To get started you will need an NFC enabled phone plus:

You can use the NFC phone SDKs for the Series 40 phones also, if you wish. In particular, these SDKs currently offer better features for testing.

Symbian C++ based development

If you’re familiar with Symbian C++ you can use the Symbian C++ APIs in a pure Symbian C++ app. To do this, you need an NFC enabled phone plus:

Symbian WRT widgets

An NFC library for API Bridge is available from the NFC API Bridge project in Nokia Developer Projects.

UI design considerations

As NFC is supported in a small (but set to grow) number of phones, it’s important to take this into account when creating your application.

In order to achieve a consistent and favourable user experience, applications should be aware of the presence of an NFC radio in the phone and check if the radio is turned on in the connectivity settings. This section provides a step-by-step guide to handling these requirements, along with relevant code snippets and references.

Check whether NFC supported

When an application starts it should check whether NFC is supported in the phones hardware and react appropriately. How the application should react depends on how the application uses NFC. Two design approaches are available:

NFC centric application

This is an application that works on NFC enabled phones only.


In this case the application should restrict its installation to NFC capable phones only and/or query whether the NFC functionality is available at runtime. Where NFC is available as a firmware upgrade (such as on the Nokia C7 phone through the Symbian Anna update), the application should ideally alert the user to upgrade the firmware with message "Please update your phone firmware to run this application" and then exit.

Upgrade your firmware.jpg

NFC enhanced application

This is an application that will works on phones without NFC phones and takes advantage of NFC only if available on a phone.


In this case the application should query whether NFC is supported in the phone’s hardware at install and runtime. If the phone is determines not to support NFC the features of the application that rely on NFC should be disabled and ideally hidden from the user. If the application detects that the phone would offer NFC after a firmware upgrade, the application may alert the user to upgrade the phone’s firmware, but continue running.

Check if the NFC radio is turned on or off

On Symbian phones the user has the option to manually turn the NFC radio on or off. This setting affects NFC enabled applications also. To provide a consistent and seamless user experience, applications using NFC should check the status of the NFC radio and alert the user to turn it on to use the application. A model user experience flow is demonstrated by the [ NFC share application]. In this application as the application starts it checks the status of the NFC radio and informs the user if the radio is off with the message "NFC is not active. Please activate NFC from Connectivity settings before using this application".

Turn nfc on.jpg

Implementation

APIs available

To determine if a phone offers NFC:

  • In a Qt or Symbian C++ application use the IsFeatureSupported method of the TFeatureSet class and test for KFeatureIdNfc (ID = 117).
  • In a Java application query the javax.microedition.contactless.version system property value for the supported JSR-257 version. If the API is supported on the phone, the property returns 1.0.


Examples

The following examples show how to implement the UX recommendations:

  • NFC Launcher (Qt/Symbian) -This example uses a separate launcher application that checks the presence ofthe NFC feature on the phone and based on that launches the main application ordisplays a notification box alerting the user that NFC is not present.Translations of the notification strings are included.
  • Mobile NFC app (Qt/Symbian)- This project is a Qt SDK NFC project template that automatically includes theNFC feature and NFC radio status checking logic. This is ideal for starting newapplication projects.
  • NfcSettings application(Qt/Symbian) - This project uses the NFC feature and NFC radio logic from theMobile NFC app template andapplies it to a very simple application that shows the availability of NFC andradio status on the phone using a simple QML UI.
  • NFCinteractor (Java ME) -This project demonstrates how to handle the NFC dependency in a Java Midlet. Itqueries the microedition.contactless.version system property value for thesupported JSR-257 version. If the API is supported on the phone, the propertyreturns 1.0.

Testing

If you choose to develop with the NFC phone SDKs for the Series 40 phones or make use of the Symbian^3 SDK with the NFC plug-in, these tools provide some emulation of NFC tags and devices suitable for application testing.

Features to emulate NFC tags and devices are planned for Qt SDK.

An NFC phone is recommended also to complete testing prior to distributing your application.

Application distribution

NFC enabled applications can be distributed as any other applications are, through Nokia Store. This article describes the requirements related to NFC feature handling and guidelines that must be implemented by the application to ensure a seamless user experience.

Requirements for the Nokia C7 phone with Symbian Anna

  • The application must handle the cases where the user has not upgraded their Nokia C7 phone's firmware
  • Only free applications are accepted
  • Only applications using the Symbian API or created using Java ME are accepted (Qt Mobility 1.2 API support, in Smart Installer, will be added in the future)
  • Optional: Check whether the NFC radio is turned on or off

Distribution to other Symbian NFC capable phones

  • Applications can be created in any of the available languages using anyavailable API (Qt, native Symbian, or Java ME)
  • Applications may be free or charged for
  • Optional: Check whether the NFC radio is turned on or off

Obtaining an NFC enabled phone

If you’re a Nokia Developer Launchpad or PRO member you can obtain an NFC enabled phone through the Prototype Device Loaning Service or the Discounted Devices Program.

As part of the Discounted Devices Program Nokia is making available an NFC Device Kit to Nokia Developer Launchpad and PRO members. The Kit includes an NFC mobile phone and sample NFC tags. You can purchase it from here: Discounted Devices Program.

If you’re not a member of Launchpad or PRO, you can find details on how to join Launchpad here.



Article Metadata
Code ExampleTested withCompatibilityArticle
Created: (16 Feb 2013)
Last edited: jure.sustersic@nokia.com (19 Aug 2011)
333 page views in the last 30 days.
×