Tools

Namespaces

Variants

Views

Actions

Search

Contents

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to launch apps available in the store using NFC LaunchApp tag

Comments

Jenesuispasbavard - Arguments other than user=default

Are there other options available other than 'user=default' for the <launch arguments> field? I'm trying to launch Nokia Drive+ Beta along with a Set Destination argument (if possible), so that I can have an NFC tag in a car that takes me straight home as soon as I put my phone there. For now, anything entered into the <launch arguments> field is ignored (seemingly).

jenesuispasbavard
14:33, 12 January 2013 (EET)

WieserSoftwareLtd - Remember, LaunchApp:WriteTag only works on an actual tag

Don't try to use it to write to the Phone's ProximityDevice, as it doesn't work like that. This only writes to a writeable tag itself.

This article explains how to launch any given application available from Windows Phone Store via NFC tag by using LaunchApp protocol provided in Windows.Networking.Proximity.ProximityDevice from Windows Phone 8.

Introduction

One of the essential features that NFC provides is launch an application when the end user tap his/her mobile device to an external tag. This feature is fundamental to many potential use cases. For example, in the car driving scenario, the end user puts the mobile device to a phone holder in the car. If the phone holder has a NFC tag on it, then once the end user fixes his mobile device to the phone holder, the mobile device will automatically launch navigation software e.g. Nokia Drive/Maps. Another user case could be for sleeping use case. The end user puts the mobile devices to his bed desk. If the desk has a NFC tag on it, the mobile device could launch an application automatically according to user's preference, such as opening a music player to play audio book, or simply switch to silent mode. Similar use cases could be for scenarios like shopping, hotel check-in, travel guide, restaurant review, etc. Launching a specific application on mobile device by tapping a tag is an essential enabler for those innovative use cases. This article will explain in details how to implement such feature on Windows Phone 8 devices.

Although Microsoft has provided some documentation about LaunchApp protocol [1][2], the quality of current version of the documentation still has room to improve. For example, examples and explanations are only for windows 8 and not yet covering windows phone 8. Therefore, it is better to have an article to explain those details for windows phone 8. We will firstly introduce what is LaunchApp protocol, then explain how to form the LaunchApp protocol for a specific app on windows phone 8, and thirdly we will describe how to write the LaunchApp content into a NFC tag, and at the end we will illustrate how the device behaves when tapping the LaunchApp tag in different scenarios.

What is the LaunchApp protocol

The definition of LaunchApp protocol can be found from the API documentation for ProximityDevice.PublishBinaryMessage. The protocol is designed to provide support for multiple platform using the same tag content, such as both for windows 8 and Windows Phone 8.

According to that, the LaunchApp content should follow the syntax below and you must specify at least one app platform and app name.

An example is given for windows 8: "user=default\tWindows\tExample.Proximity.JS_8wekyb3d8bbwe!Proximity.App", where the <launch arguments> is "user=default", the <app platform> is "Windows", and the app name is in the format of <package family name>!<app Id>, which is "Example.Proximity.JS_8wekyb3d8bbwe!Proximity.App" in the example.

For windows phone 8, the syntax of LaunchApp still applies. The <launch arguments> is "user=default" and the <app platform> is "WindowsPhone". However, the format of <app name> is different than windows 8. The <app name> is {<app id>}, where app id is in the format of <8digi hex>-<4digi hex>-<4digi hex>-<12digi hex>. For example Nokia MixRadio's app id is f5874252-1f04-4c3f-a335-4fa3b7b85329. Then the content of LaunchApp for Nokia MixRadio should be "user=default\tWindowsPhone\t{f5874252-1f04-4c3f-a335-4fa3b7b85329}". Please note that the minimum size of the LaunchApp tag for windows phone 8 is 128 bytes.

How to form LaunchApp content for a specific application on Windows Phone 8

As explained in the previous section, the key to form the LaunchApp content for Windows Phone 8 is to obtain the app id of the application. Depending on the scenarios, there are different ways to get the app id of the desired application

How to get the app id of the current running application

If you want to get the app id of the current running application in C# code, you can simply use the Windows.ApplicationModel.Store.CurrentApp.appId to do so, which documentation can be found from here

var appId = Windows.ApplicationModel.Store.CurrentApp.AppId;

Or you can use the System.Xml.Linq.XDocument to pass WMAppManifest.xml to get product ID (same as app id once the app is published)

How to get the app id of an application installed on the device

If you want to get the app id of an application installed on the device, you can go to application list and long press the app you want, click "share", choose any email account, then copy the string after "?appid=" from the URL.

Check if the target tag has enough payload for the LaunchApp content. If the LaunchApp has only windows phone 8 entry, then the required payload size is 128 bytes. WriteableTag protocol is defined in ProximityDevice.PublishBinaryMessage

How the windows phone device behaves when tapping a tag with LaunchApp content

When the end user taps his/her windows phone 8 device to the tap with LaunchApp tag, the device behaves differently depending on whether the app has been already installed on the device or not. Here we use Nokia MixRadio as an example app for LaunchApp tag with windows phone 8 device.

How the windows phone 8 behaves if the app the tag linked to is not installed

If the application is not yet installed on the windows phone 8 device when tapping the tag, then the device will ask if the end user wants to install the app. If the end user selects "get app", then the device will launch store to install the app.

If the application is not installed and is not yet published to store, then the device will display general info asking to install the app. Then if you try to install the app by clicking "get app", the system will show an error message as the app cannot be found from the store.

How the windows phone 8 device behaves if the app the tag linked to is installed

If the application is already installed on the windows phone 8 device, then the device will ask if the end user wants to launch the app or not.