×
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 -)
hamishwillee (Talk | contribs)
m (Hamishwillee -)
(25 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Near Field Communication (NFC)]][[Category:Qt]][[Category:Java ME]][[Category:Symbian C++]][[Category:Symbian Web Runtime]]
+
[[Category:Near Field Communication (NFC)]][[Category:Qt]][[Category:Java ME]][[Category:Symbian C++]][[Category:Symbian Web Runtime]][[Category:Symbian]][[Category:Code Snippet]][[Category:Getting Started]]
 
{{Abstract|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.}}
 
{{Abstract|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.}}
 
   
 
   
Line 6: Line 6:
 
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.  
 
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===
 
===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.  
 
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 [[#Obtaining an NFC enabled phone|an NFC enabled phone]] and the [http://www.developer.nokia.com/info/sw.nokia.com/id/da8df288-e615-443d-be5c-00c8a72435f8/Qt_SDK.html Qt SDK 1.1] plus:
+
To get started you need:
* [https://projects.developer.nokia.com/QtM12bSymb Qt Mobility 1.2 beta for Symbian add on for the Qt SDK 1.1]: Installation instructions are provided in the package.
+
*[[#Obtaining an NFC enabled phone|an NFC enabled phone]]  
*[http://doc.qt.nokia.com/qtmobility-1.2.0-beta1/connectivity-api.htmlConnectivity API documentation].
+
*The [http://www.developer.nokia.com/info/sw.nokia.com/id/da8df288-e615-443d-be5c-00c8a72435f8/Qt_SDK.html Qt SDK]  
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.
+
*[http://doc.qt.nokia.com/qtmobility/connectivity-api.html Connectivity API documentation].
+
 
Further example apps are the [https://projects.developer.nokia.com/nfccorkboards NFC Corkboard] (demonstrates NDEF reading and writing) and [https://projects.developer.nokia.com/nfcchat NFC Chat] (LLCP peer-to-peer communication). In addition, you can download a [http://www.slideshare.net/andreasjakl/nokia-nfc-development step-by-step walkthrough tutorial] that explains how to code these apps plus the basic Qt concepts required for understanding the interaction.
+
In the SDK you will find Qt Mobility 1.2. binaries that can be installed on a Nokia C7 Device with Symbian Anna. The package enables development with the Symbian C++ NFC API also.
 
   
 
   
 +
Further here are some example apps you might want to use as a starting point:
 +
*[https://projects.developer.nokia.com/nfcinfo Nfc Info] (show information about tags and parse NDEF messages, including Smart Posters and vCards)
 +
*[https://projects.developer.nokia.com/nfccorkboards Nfc Corkboard] (demonstrates NDEF reading and writing)
 +
*[https://projects.developer.nokia.com/nfcchat Nfc Chat] (LLCP peer-to-peer communication).
 +
In addition, you can download a [http://www.slideshare.net/andreasjakl/nokia-nfc-development step-by-step walkthrough tutorial] that explains how to code the latter two apps plus the basic Qt concepts required for understanding the interaction.
 +
 
===Java ME based development===
 
===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 [[#Obtaining an NFC enabled phone| an NFC enabled phone]] plus:
 
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 [[#Obtaining an NFC enabled phone| an NFC enabled phone]] plus:
 
*[http://netbeans.org/ NetBeans] or [http://www.eclipse.org Eclipse] IDE
 
*[http://netbeans.org/ NetBeans] or [http://www.eclipse.org Eclipse] IDE
*[http://www.developer.nokia.com/info/sw.nokia.com/id/571baaf2-042a-4662-9d43-a5a68eb42d9d/Symbian_3_SDK_v1_0_en.zip.htmlSymbian^3 SDK 1.0]
+
*[http://www.developer.nokia.com/info/sw.nokia.com/id/571baaf2-042a-4662-9d43-a5a68eb42d9d/Symbian_3_SDK_v1_0_en.zip.html Symbian^3 SDK 1.0]
*[http://www.developer.nokia.com/info/sw.nokia.com/id/fb8e0f5a-75db-4459-a82e-6eee9e569a90/NFC_Plug_in_Symbian_3_SDK.htmlNFC plug-in for the Nokia Symbian^3 SDK 1.0]
+
*[http://www.developer.nokia.com/info/sw.nokia.com/id/fb8e0f5a-75db-4459-a82e-6eee9e569a90/NFC_Plug_in_Symbian_3_SDK.html NFC plug-in for the Nokia Symbian^3 SDK 1.0]
*[http://library.forum.nokia.com/topic/Java_Developers_Library/GUID-9248DD7F-23BE-40A6-A8DC-823783443F10.html?resultof=%22%4e%46%43%22%20%22%6e%66%63%22%20Developer's guide]
+
*[http://library.developer.nokia.com/topic/Java_Developers_Library/GUID-9248DD7F-23BE-40A6-A8DC-823783443F10.html?resultof=%22%4e%46%43%22%20%22%6e%66%63%22%20 Developer's guide]
 
You can use the [http://www.developer.nokia.com/Resources/Tools_and_downloads/Archive.xhtml NFC phone SDKs for the Series 40 phones] also, if you wish. In particular, these SDKs currently offer better features for testing.
 
You can use the [http://www.developer.nokia.com/Resources/Tools_and_downloads/Archive.xhtml NFC phone SDKs for the Series 40 phones] also, if you wish. In particular, these SDKs currently offer better features for testing.
 
   
 
   
Line 29: Line 36:
 
   
 
   
 
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 [[#Obtaining an NFC enabled phone|an NFC enabled phone]] plus:
 
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 [[#Obtaining an NFC enabled phone|an NFC enabled phone]] plus:
*[http://www.developer.nokia.com/info/sw.nokia.com/id/dbb8841d-832c-43a6-be13-f78119a2b4cb.htmlCarbide.c++]
+
*[http://www.developer.nokia.com/info/sw.nokia.com/id/dbb8841d-832c-43a6-be13-f78119a2b4cb.html Carbide.c++]
*[http://www.developer.nokia.com/info/sw.nokia.com/id/571baaf2-042a-4662-9d43-a5a68eb42d9d/Symbian_3_SDK_v1_0_en.zip.htmlSymbian^3 SDK 1.0]
+
*[http://www.developer.nokia.com/info/sw.nokia.com/id/571baaf2-042a-4662-9d43-a5a68eb42d9d/Symbian_3_SDK_v1_0_en.zip.html Symbian^3 SDK 1.0]
*[http://www.developer.nokia.com/info/sw.nokia.com/id/fb8e0f5a-75db-4459-a82e-6eee9e569a90/NFC_Plug_in_Symbian_3_SDK.htmlNFC plug-in for the Nokia Symbian^3 SDK]
+
*[http://www.developer.nokia.com/info/sw.nokia.com/id/fb8e0f5a-75db-4459-a82e-6eee9e569a90/NFC_Plug_in_Symbian_3_SDK.html NFC plug-in for the Nokia Symbian^3 SDK]
*[http://library.developer.nokia.com/topic/GUID-E35887BB-7E58-438C-AA27-97B2CDE7E069/GUID-76C9285D-5C89-4CBC-AB05-F14D6A95BC90.html#GUID-76C9285D-5C89-4CBC-AB05-F14D6A95BC90API documentation]
+
*[http://library.developer.nokia.com/topic/GUID-E35887BB-7E58-438C-AA27-97B2CDE7E069/GUID-76C9285D-5C89-4CBC-AB05-F14D6A95BC90.html#GUID-76C9285D-5C89-4CBC-AB05-F14D6A95BC90 API documentation]
*[http://www.developer.nokia.com/Community/Wiki/Making_Bluetooth_connection_by_touching_two_NFC_enabled_(C7)_phonesMaking Bluetooth connection by touching two NFC enabled (C7) phones ]
+
  
 
===Symbian WRT widgets===
 
===Symbian WRT widgets===
An NFC library for [https://www.developer.nokia.com/info/sw.nokia.com/id/d697a64f-ddae-4937-8151-be157b542d26/ApiBridge.html API Bridge] is available from the [http://projects.developer.nokia.com/NFCApbibridge NFC API Bridge] project in Nokia Developer Projects.  
+
 
 +
An NFC library for [http://www.developer.nokia.com/info/sw.nokia.com/id/d697a64f-ddae-4937-8151-be157b542d26/ApiBridge.html API Bridge] is available from the [http://projects.developer.nokia.com/NFCApbibridge NFC API Bridge] project in Nokia Developer Projects.  
 
   
 
   
 
== UI design considerations==
 
== UI design considerations==
Line 43: Line 50:
 
   
 
   
 
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.
 
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===
 
===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:
 
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====
+
{| class="wikitable"
+
|-
This is an application that works on NFC enabled phones only.
+
! NFC centric application !! ! width="50%" | NFC enhanced application
+
|-
+
| This is an application that works on NFC enabled phones only. || 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 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.  
+
| 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. || 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.
+
<gallery>
+
File:Upgrade_your_firmware.jpg|Caption1
+
</gallery>
+
   
+
====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.
 
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.
+
|}
 +
[[File:upgrade your firmware.jpg]]
 +
 
 
===Check if the NFC radio is turned on or off===
 
===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.  
 
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.
 
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".
+
At start the application queries the status of 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|Caption1
+
</gallery>
+
 
   
 
   
 +
[[File:turn nfc on.jpg]]
 +
 
===Implementation===
 
===Implementation===
+
 
 
   
 
   
 
====APIs available====
 
====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).
+
To determine if a device supports NFC:
 +
* In a Qt or Symbian C++ application use the ''IsFeatureSupported'' method using the [http://library.developer.nokia.com/topic/S60_5th_Edition_Cpp_Developers_Library/GUID-9488F628-B7CD-4211-8508-F7D9C69D8D05.html?resultof=%22%66%65%61%74%75%72%65%22%20%22%66%65%61%74%75%72%22%20%22%64%69%73%63%6f%76%65%72%79%22%20%22%64%69%73%63%6f%76%65%72%69%22%20%22%41%50%49%22%20%22%61%70%69%22%20 Feature Discovery API]  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.
 
* 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====
 
====Examples====
 +
 
The following examples show how to implement the UX recommendations:
 
The following examples show how to implement the UX recommendations:
*[http://projects.developer.nokia.com/nfcnppexample 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.
+
*[http://projects.developer.nokia.com/nfclauncher NFC Launcher (Qt/Symbian)] -This example uses a separate launcher application that checks the presence of NFC on the phone and based on that either launches the main application, or displays a notification box alerting the user that NFC is not present.Translations of the notification strings are included.
*[http://projects.developer.nokia.com/mobilenfcapp 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.
+
*[http://projects.developer.nokia.com/mobilenfcapp Mobile NFC app (Qt/Symbian)]- This project is a Qt SDK NFC project template that automatically includes both NFC feature and NFC radio status checking logic. This is ideal for starting new NFC application projects in Qt.
*[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 and applies a very simple QML based UI that shows both the availability of NFC and radio status on the phone.
*[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. It queries the ''microedition.contactless.version'' system property value (JSR-257). If the API is supported on the phone, the property returns 1.0.
+
 
+
 
== Testing==
 
== Testing==
+
 
 +
The Qt SDK does provide simulation of NFC tag related events and a simple NDEF editor to customize vitrual tag content.
 +
 
 
If you choose to develop with the [http://www.developer.nokia.com/Resources/Tools_and_downloads/Archive.xhtml NFC phone SDKs for the Series 40] phones or make use of the [http://www.developer.nokia.com/info/sw.nokia.com/id/571baaf2-042a-4662-9d43-a5a68eb42d9d/Symbian_3_SDK_v1_0_en.zip.html Symbian^3 SDK] with the [http://www.developer.nokia.com/info/sw.nokia.com/id/fb8e0f5a-75db-4459-a82e-6eee9e569a90/NFC_Plug_in_Symbian_3_SDK.html NFC plug-in], these tools provide some emulation of NFC tags and devices suitable for application testing.
 
If you choose to develop with the [http://www.developer.nokia.com/Resources/Tools_and_downloads/Archive.xhtml NFC phone SDKs for the Series 40] phones or make use of the [http://www.developer.nokia.com/info/sw.nokia.com/id/571baaf2-042a-4662-9d43-a5a68eb42d9d/Symbian_3_SDK_v1_0_en.zip.html Symbian^3 SDK] with the [http://www.developer.nokia.com/info/sw.nokia.com/id/fb8e0f5a-75db-4459-a82e-6eee9e569a90/NFC_Plug_in_Symbian_3_SDK.html 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.
 
 
   
 
   
 
[[#Obtaining an NFC enabled phone|An NFC phone]] is recommended also to complete testing prior to distributing your application.
 
[[#Obtaining an NFC enabled phone|An NFC phone]] is recommended also to complete testing prior to distributing your application.
 
   
 
   
==Application distribution==
+
==Application distribution via Store==
 
   
 
   
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.
+
NFC enabled applications can be distributed as any other application through Nokia Store. This section describes the requirements related to NFC feature handling and guidelines that must be implemented by the application to ensure a seamless user experience. These requirements need to be addressed by the publisher before submitting the application to Quality Assurance
 
   
 
   
 
===Requirements for the Nokia C7 phone with Symbian Anna===
 
===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  
+
* The application '''must''' handle the cases where the user has not upgraded their Nokia C7 phone's firmware using the approach outlined above
 
* Only free applications are accepted  
 
* 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)
+
* Check whether the NFC radio is turned on or off
* 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
+
 
   
 
   
 +
===Distribution to other Symbian NFC (also MeeGo) capable phones===
 +
 +
* Applications may be free or premium
 +
* Check whether the NFC radio is turned on or off
 +
 
== Obtaining an NFC enabled phone ==
 
== Obtaining an NFC enabled phone ==
 
   
 
   
If you’re a Nokia Developer Launchpad or PRO member you can obtain an NFC enabled phone through the [https://forumnokia.secure.force.com/apex/Protodevice_Loaning_Service Prototype Device Loaning Service] or the [https://forumnokia.secure.force.com/apex/DDP Discounted Devices Program].
+
If you’re a Nokia Developer Launchpad or PRO member you can obtain an NFC enabled phone through the [https://forumnokia.secure.force.com/apex/Protodevice_Loaning_Service Prototype Device Loaning Service] or the [https://forumnokia.secure.force.com/apex/DDP Discounted Devices Program] (link requres you have an active Nokia Developer Launchpad or PRO account/login).
 
   
 
   
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: [https://forumnokia.secure.force.com/apex/DDP 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: [https://forumnokia.secure.force.com/apex/DDP Discounted Devices Program] (link requres you have an active Nokia Developer Launchpad or PRO account/login)..
 
   
 
   
 
If you’re not a member of Launchpad or PRO, you can find details on how to join Launchpad [http://www.developer.nokia.com/Developer_Programs/Launchpad.xhtml here].  
 
If you’re not a member of Launchpad or PRO, you can find details on how to join Launchpad [http://www.developer.nokia.com/Developer_Programs/Launchpad.xhtml here].  
 +
 
   
 
   
+
{{ArticleMetaData <!-- v1.2 -->
+
+
+
{{ArticleMetaData
+
+
 
|sourcecode= [https://projects.developer.nokia.com/home/project/explore#action=results&c%5B%5D=336&f=&tab=active&page=1&numresults=10 Examples in Nokia Developer Projects]
 
|sourcecode= [https://projects.developer.nokia.com/home/project/explore#action=results&c%5B%5D=336&f=&tab=active&page=1&numresults=10 Examples in Nokia Developer Projects]
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices=  
+
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
|sdk= [https://www.developer.nokia.com/info/sw.nokia.com/id/da8df288-e615-443d-be5c-00c8a72435f8/Qt_SDK.html Qt SDK] or [https://www.developer.nokia.com/info/sw.nokia.com/id/4a94a6d5-c7f4-487f-b1d0-c9f269030dc1/Nokia_SDK_for_Java.html Nokia SDK for Java]
+
|sdk= [http://www.developer.nokia.com/info/sw.nokia.com/id/da8df288-e615-443d-be5c-00c8a72435f8/Qt_SDK.html Qt SDK] or [http://www.developer.nokia.com/info/sw.nokia.com/id/4a94a6d5-c7f4-487f-b1d0-c9f269030dc1/Nokia_SDK_for_Java.html Nokia SDK for Java]
 
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
|devicecompatability= [https://www.developer.nokia.com/Devices/Device_specifications/?filter1=symbian&filter2=nfc Symbian phones with NFC]
+
|devicecompatability= [http://www.developer.nokia.com/Devices/Device_specifications/?filter1=symbian&filter2=nfc Symbian phones with NFC]
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
+
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
|id= <!-- Article Id (Knowledge base articles only) -->
+
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
|creationdate= <!-- Format DD month, YYYY -->
+
|translated-by= <!-- [[User:XXXX]] -->
|author= <!-- Display as link [[User:username]] -->
+
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20110818
 +
|author= [[User:Rebloor]]
 
}}
 
}}

Revision as of 09:03, 27 November 2012

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:

In the SDK you will find Qt Mobility 1.2. binaries that can be installed on a Nokia C7 Device with Symbian Anna. The package enables development with the Symbian C++ NFC API also.

Further here are some example apps you might want to use as a starting point:

  • Nfc Info (show information about tags and parse NDEF messages, including Smart Posters and vCards)
  • Nfc Corkboard (demonstrates NDEF reading and writing)
  • Nfc Chat (LLCP peer-to-peer communication).

In addition, you can download a step-by-step walkthrough tutorial that explains how to code the latter two 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 NFC enhanced application
This is an application that works on NFC enabled phones only. 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 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. 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.

Upgrade your firmware.jpg

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. At start the application queries the status of 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 device supports NFC:

  • In a Qt or Symbian C++ application use the IsFeatureSupported method using the Feature Discovery API 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 of NFC on the phone and based on that either launches the main application, or displays 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 both NFC feature and NFC radio status checking logic. This is ideal for starting new NFC application projects in Qt.
  • NfcSettings application(Qt/Symbian) - This project uses the NFC feature and NFC radio logic from theMobile NFC app template and applies a very simple QML based UI that shows both the availability of NFC and radio status on the phone.
  • NFCinteractor (Java ME) - This project demonstrates how to handle the NFC dependency in a Java Midlet. It queries the microedition.contactless.version system property value (JSR-257). If the API is supported on the phone, the property returns 1.0.

Testing

The Qt SDK does provide simulation of NFC tag related events and a simple NDEF editor to customize vitrual tag content.

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.

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

Application distribution via Store

NFC enabled applications can be distributed as any other application through Nokia Store. This section describes the requirements related to NFC feature handling and guidelines that must be implemented by the application to ensure a seamless user experience. These requirements need to be addressed by the publisher before submitting the application to Quality Assurance

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 using the approach outlined above
  • Only free applications are accepted
  • Check whether the NFC radio is turned on or off

Distribution to other Symbian NFC (also MeeGo) capable phones

  • Applications may be free or premium
  • 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 (link requres you have an active Nokia Developer Launchpad or PRO account/login).

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 (link requres you have an active Nokia Developer Launchpad or PRO account/login)..

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: rebloor (18 Aug 2011)
Last edited: hamishwillee (27 Nov 2012)
244 page views in the last 30 days.
×