Tag Archives: UWP

Using Cortana to interact with your customers (10 by 10)

This week’s theme in our Windows 10 by 10 development series is extending customer engagement using the Windows 10 without your users even entering your app. Last week’s topic, Live Tiles and notifications showed how one way to extend your app’s experience, now let’s show how to use the Windows 10 personal assistant, Cortana, to do so. To illustrate what you can do with Cortana, we’ll be using the AdventureWorks sample on GitHub as our base for the code snippets below in this blog post.

In this blog post, we’ll talk about what Cortana is, how to make Cortana have a meaningful conversation with your customer, the initial work needed to get Cortana integrated into your app, and then two of the many ways your app could interact with your end user depending on the scenario.


What exactly is Cortana?

One of the neatest capabilities introduced in Windows 10 is the Cortana personal assistant, who joins us from Windows Phone. Cortana is a front and center experience in Windows 10 that users can engage with via natural language. With Cortana, users can engage with Windows (both the core OS, but also apps such as yours) the same way they would speak to a person. For example, think about the questions that only your app can answer to the user using Cortana’s voice such as “When is my next trip?”, “Search for a radio station”, “Is Jack online?”. Your app can then answer these questions by providing the answer for Cortana to say and display. Think about tasks that the user can ask Cortana to do in your app such as: “Cancel my trip to London”, “Like this station”, “Tell Jack I’m running late”.

Voice commands can provide quick access to info inside the app when you use voice command as deep links into your application. Just as you currently create a tile to provide a shortcut into your app, you can also use a voice command to serve as a shortcut to a screen inside your app. And just as you give the user the ability to pin that recent trip they created in your app onto their Start screen, you can also enable that same user to use a voice command in the Cortana experience to get them to that same trip. This ability can make your users more productive, and your app’s experience more accessible to them.

By extending Cortana, you can engage and delight your users by empowering them to get things done with a quick voice command. This blog post isn’t on the customer features of Cortana however, it is about how you can integrate it into your app.

Hey Cortana, let’s have a conversation

Since interacting with Cortana is speech based, your user experience needs to flow as if you were having a natural conversation with them. There are general Cortana design guidelines on MSDN that explain best practices for user interactions. For successful Cortana interactions, follow these principles as well: efficient, relevant, clear and trustworthy interactions.

What do they actually mean?

  • Efficient: Less is more. Be concise and use as few words as possible without losing meaning
  • Relevant: Keep the topic on track. If I request my favorite ABBA song be added to my playlist, don’t tell me my battery is low as well. Instead, confirm to me I’ll be rocking out to ABBA shortly :)
  • Clear: Write the conversation for your audience. Be sure the dialogue uses everyday language instead of jargon that few people may know.
  • Trustworthy: Responses should accurately represent what is happening and respect user preferences. If your app hasn’t completed a task, don’t say it has. And don’t return dialog that someone may not want to hear out loud

cortanaBestFriendAlso, you should consider localizing your Cortana interactions, especially if you’ve already localized the rest of your app or are making it available globally. Cortana is currently available in the US, UK, China, France, Italy, Germany and Spain, with more markets coming on board in the future. Localizing and adapting the interactions will aid in encouraging your customers to use the Cortana feature of your app.

Teaching Cortana what to respond to

Cortana uses a Voice Command Definition (VCD) file to define the speech interactions the user can have with your app. This file can be XML based or generated via code. Once your app runs for the first time, the command sets in the VCD will be installed. Here is a quick sample VCD:

<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
  <CommandSet xml:lang="en-us" Name="AdventureWorksCommandSet_en-us">
    <CommandPrefix> Adventure Works, </CommandPrefix>
    <Example> Show trip to London </Example>

    <Command Name="showTripToDestination">
      <Example> show trip to London </Example>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> show trip to {destination} </ListenFor>
      <Feedback> Showing trip to {destination} </Feedback>

    <PhraseList Label="destination">
      <Item> London </Item>
      <Item> Dallas </Item>

<!-- Other CommandSets for other languages -->

When your app is activated, InstallCommandSetsFromStorageFileAsync should be called in the OnLaunched app event handler to register the commands that Cortana should listen for. Keep in mind that if a device backup is restored and your app is reinstalled, voice command data is not preserved. To ensure the voice command data for your app stays intact, consider initializing your VCD file each time your app launches or activates. You can also store a setting that indicates if the VCD is currently installed, then check that setting each time your app launches or activates. Here is some basic code to get the VCD loaded into your app:

var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///CortanaVcd.xml"));

await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.InstallCommandSetsFromStorageFileAsync(storageFile);

Being dynamic

Now that we have the grammar initialized, we can dynamically alter it at runtime. Here is a simple example of dynamically altering the VCD we loaded above:

private Windows.ApplicationModel.VoiceCommands.VoiceCommnadDefinition.VoiceCommandSet commandSetEnUs;

if (Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.InstalledCommandSets.TryGetValue("AdventureWorksCommandSet_en-us", out commandSetEnUs))
  // this code will fully replace the destination list
  await commandSetEnUs.SetPhraseListAsync("destination", new string[] {"Chicago", "Seattle", "New York", "Phoenix"});

How should my app interact with Cortana?

There are a number of ways for your app to interact with Cortana. The three most typical ways are:

  1. Have Cortana launch your app. Along with launching your app to the foreground, you can specify a deep link for an action or command to execute within the app.
  2. Within Cortana, allow simple user interaction for your app to store or return data in the background.
  3. Within Cortana, let your app and user interact with each other.

Launching your app to the foreground

If you have a complex task and want the user to jump directly into your app, using Cortana is a great solution. Since some complex tasks can actually be done faster and more accurately by voice commands, this may be the way to go.

protected override void OnActivated(IActivatedEventArgs e)
  // Was the app activated by a voice command?
  if (e.Kind != Windows.ApplicationModel.Activation.ActivationKind.VoiceCommand)

  var commandArgs = e as Windows.ApplicationModel.Activation.VoiceCommandActivatedEventArgs;
  var navigationParameterString = "";

  Windows.ApplicationModel.VoiceCommands.VoiceCommand.SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;

  // Get the name of the voice command and the text spoken
  string voiceCommandName = speechRecognitionResult.RulePath[0];
  string textSpoken = speechRecognitionResult.Text;

  // The commandMode is either "voice" or "text", and it indicates how the voice command was entered by the user.
  // Apps should respect "text" mode by providing feedback in a silent form.
  string commandMode = this.SemanticInterpretation("commandMode", speechRecognitionResult);

  switch (voiceCommandName)
    case "showTripToDestination":
      // Access the value of the {destination} phrase in the voice command
      string destination = speechRecognitionResult.SemanticInterpretation.Properties["destination"][0];

      // Create a navigation parameter string to pass to the page
      navigationParameterString = string.Format("{0}|{1}|{2}|{3}",
                    voiceCommandName, commandMode, textSpoken, destination);

      // Set the page where to navigate for this voice command
      navigateToPageType = typeof(TripPage);

      // There is no match for the voice command name. Navigate to MainPage
      navigateToPageType = typeof(MainPage);

  if (this.rootFrame == null)
    // App needs to create a new Frame, not shown

  if (!this.rootFrame.Navigate(navigateToPageType, navigationParameterString))
    throw new Exception("Failed to create voice command page");

Simple interaction to store or return data to/from your app within Cortana

Now that you have Cortana connected to your VCD and executing basic interactions, we’ll dive into having Cortana do some of the heavier lifting. For example, you can have Cortana provide data back to the user, or store some data. MSDN has a comprehensive walkthrough for setting up a background app for Cortana. Here’s a quick summary of the steps.

  1. Create a Windows Runtime Component project in your solution.
  2. Create a new class that implements the IBackgroundTask interface, which will serve as our app service.
  3. In your UWP app’s Package.appxmanifest, add a new Extension for the new app service. The MSDN documentation goes through this step in detail.

Here is a sample of what the Package.appxmanifest XML will look like:

        <Extension Category="windows.appService"
          <AppService Name="AdventureWorksVoiceCommandService"/>

Once launched, the app background service has 0.5 seconds to call ReportSuccessAsync. Cortana uses the data provided by the app to show and verbalize the feedback specified in the VCD file. If the app takes longer than 0.5 seconds to return from the call, Cortana inserts a hand-off screen, as shown below. Cortana displays the hand-off screen until the application calls ReportSuccessAsync, or for up to 5 seconds. If the app service doesn’t call ReportSuccessAsync, or any of the VoiceCommandServiceConnection methods that provide Cortana with information, the user receives an error message and the app service call is cancelled.


Here is the basic code needed for the IBackgroundTask implementation to act as an app service:

using Windows.ApplicationModel.Background;

namespace AdventureWorks.VoiceCommands
  public sealed class AdventureWorksVoiceCommandService : IBackgroundTask
    public void Run(IBackgroundTaskInstance taskInstance)
      BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();

      // TODO: Insert code

Having user interactions within Cortana

Now that you know the basics, you’re ready for richer user interactions within Cortana. The app can specify different types of screens to support functionality that includes:

  • Successful completion
  • Hand-off
  • Progress
  • Confirmation
  • Disambiguation
  • Error

Let’s dive into one of these scenarios above: disambiguation. There are times where your app will have multiple choices to return. Your app then needs to disambiguate what to do next. If the user was picking music and they could pick between ABBA, Nickelback or White Snake for their favorite band to play next, Cortana can handle this. The code below from the Adventure Works sample will show you how to handle disambiguation from within your app service,:

// Create a VoiceCommandUserMessage for the initial question.
var userPrompt = new VoiceCommandUserMessage();
userPrompt.DisplayMessage = "Which one do you want to cancel?";
userPrompt.SpokenMessage = "Which Chicago trip do you wanna cancel?";
// Create a VoiceCommandUserMessage for the second question,
// in case Cortana needs to reprompt.
var userReprompt = new VoiceCommandUserMessage();
userReprompt.DisplayMessage = “Which one did you want to cancel?”;
userReprompt.SpokenMessage = "Which one did you wanna to cancel?";

// Create the list of content tiles to show the selection items.
var destinationsContentTiles = new List<VoiceCommandContentTile>();

// create your VoiceCommandContentTiles
for(int i=0; i < 5; i++)
  var destinationTile = new VoiceCommandContentTile();
  destinationTile.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;
  // The AppContext is optional. 
  // Replace this value with something specific to your app. 
  destinationTile.AppContext = "id_Vegas_00" + i;
  destinationTile.Title = "Tech Conference";

  destinationTile.TextLine1 = "May " + i + "th";


// Create the disambiguation response.
var response = VoiceCommandResponse.CreateResponseForPrompt(userPrompt, userReprompt, destinationsContentTiles);

// Request that Cortana shows the disambiguation screen.
var voiceCommandDisambiguationResult = await voiceServiceConnection.RequestDisambiguationAsync(response);

if (voiceCommandDisambiguationResult != null)
   // Use the voiceCommandDisambiguationResult.SelectedItem to take action.
   // Call Cortana to present the next screen in .5 seconds
   // and avoid a transition screen.

Wrapping up Cortana for now

We hope that you now better understand how Cortana can easily be added to your application, opening up a multitude of interaction models with your customers. From launching your app, all the way to a complex interaction without them even launching the app, Cortana integration really does add to user engagement. We hope that you thought about how your app could take advantage of Cortana’s extensibility – even if it’s simply providing a new way of deeply linking into your app experience.

If you feel Cortana makes sense for your apps, definitely take advantage of it. And once your updated app is submitted, be sure to redeem the “Adding Cortana to your app” DVLUP challenge, so you can claim points and XP for updating your apps. Also, let us know via @WindowsDev and #Win10x10 – we love to hear what developers are building on Windows.

Also, check out the full Windows 10 by 10 development series schedule for the topics we will be covering in the series. For more on Cortana, check back here in a couple weeks as we dive into using Cortana’s natural language capabilities in your app to deliver a more personal user experience.

Additional Resources on Extending Cortana

For more information on extending Cortana, below are some additional resources that we believe may be of use to you.

Using promotional codes for your apps: a walkthrough and suggested uses

On July 29, we launched a highly requested new feature in Dev Center: promotional codes. Today I want to share more details about this feature, how and when to best use it.

Promotional codes enable developers to obtain codes that they can give to customers or app testers to redeem for a specific app or specific IAP in place of payment. With promotional codes, developers can generate up to 250 codes for every app or in-app product every six months. These codes work across Windows Phone 7.x/8.x, Windows 8.x as well as Windows 10. Each code has a six-month expiration date. Promotional codes have no cost, cannot be sold, generate no revenue, and are regulated by the App Developer Agreement (section 3.k). You’ll want to review the Agreement to understand all of the terms that apply.

These codes can be used in a variety of situations:

  • Share with app reviewers or testers to allow them to try out your app
  • Marketing campaigns to drive app adoption
  • Goodwill credit for customers experiencing an issue with your app
  • Drive customer reengagement

Promotional codes are generated in batches of any amount up to the 250 every 6 months. For example, you can create one batch of 100 codes for customer support and another batch of 150 codes for a marketing program in one 6-month period.

The promotional code flow below illustrates how you generate codes in Dev Center and distribute them.

  1. Generate codes in Dev Center: On the “promotional codes” feature in the Monetization section for your app, click Order codes. Select the app or IAP, define a name for the order, specify the quantity, and order the codes. The codes are usually ready for download within 60 minutes, but some may take up to 24 hours to generate.
    Once the codes are generated you’ll be able to download them in a .tsv (tab-separated value) file directly from Dev Center. This file contains the codes, expiration dates, and pre-generated URLs for you to share with your consumers, along with other info about that specific batch of codes.
  2. Distribute codes: Provide the URL or code to each customer, reviewer or tester. Using the URL will link the customer directly to the code redemption page, and the promotional code automatically populates so no code input is necessary. Should you provide the code itself rather than the URL, also inform your customers to visit http://microsoft.com/redeem to redeem the code.You may use any mechanism you want (for example, email) to provide the code to the user. 
  3. Users redeem the code and obtain the app or IAP: Customers can click on the URL provided or log onto microsoft.com/redeem and enter the code. Once the code is entered and validated, the customer will see a link to the app page in the Store.
    • If the code is for an app, the customer can click Install to get it at no cost.
    • If the code is for an IAP and the customer doesn’t have the app already, the page that is displayed is for the app, and the customer can then install the app first (which can be done via the link provided on the redemption confirmation screen) in order to use the IAP.
    • If the customer already has the app, the app page in the Store will let them know they already own it.

    NOTE: Some customers redeeming codes might see the button Buy instead of Install, for example when using Windows 8 or Windows Phone 8.1. If the customer is using a promotional code, they will not be charged when they click Buy. Instead, the Store will inform the customer that they already own the app, and proceed to install it.

  4. Track code usage in Dev Center: Any time you want to, you can validate how many codes are still available (not yet redeemed) for each batch, and see when the codes in each batch will expire. While Dev Center tracks the number of codes redeemed, it does not track redemption of individual codes (or which users redeemed a code).

Remember, you can generate new batches of codes (up to 250 every six months for each app or IAP).

For more information, refer to the promotional codes documentation and the App Developer Agreement.

Try out the promotional codes for your apps, and please keep sending your feedback through user voice.


.NET Native – What it means for Universal Windows Platform (UWP) developers

This blog was written by Daniel Jacobson, Program Manager

What is .NET Native?

.NET Native is a precompilation technology for building Universal Windows apps in Visual Studio 2015. The .NET Native toolchain will compile your managed IL binaries into native binaries. Every managed (C# or VB) Universal Windows app will utilize this new technology. The applications are automatically compiled to native code before they reach consumer devices. If you’d like to dive deeper in how it works, I highly recommend reading more on it at MSDN.

How does .NET Native impact me and my app?

Your mileage likely will vary, but for most cases your app will start up faster, perform better, and consume fewer system resources.

  • Up to 60% performance improvement on cold startup times
  • Up to 40% performance improvement on warm startup times
  • Less memory consumption of your app when compiled natively
  • No dependencies on the desktop .NET Runtime installed on the system
  • Since your app is compiled natively, you get the performance benefits associated with native code (think C++ performance)
  • You can still take advantage of the industry-leading C# or VB programming languages, and the tools associated with them
  • You can continue to use the comprehensive and consistent programming model available with .NET– with extensive APIs to write business logic, built-in memory management, and exception handling.

You get the best of both worlds, managed development experience with C++ performance. How cool is that?

Debug versus Release compile configuration differences

.NET Native compilation is a complex process, and that makes it a little slower when compared to classic .NET compilation. The benefits mentioned above come at a cost of compilation time. You could choose to compile natively every time you want to run your app, but you’d be spending more time waiting for the build to finish. The Visual Studio tooling is designed to address this and create the smoothest possible developer experience.

When you build and run in “Debug” configuration, you are running IL code against the CoreCLR packaged within your application. The .NET system assemblies are packaged alongside your application code, and your application takes a dependency on the Microsoft.NET.CoreRuntime (CoreCLR) package.

This means you get the best development experience possible – fast compilation and deployment, rich debugging and diagnostics, and all of the other tools you are accustomed to with .NET development.

When you switch to “Release” mode, by default your app utilizes the .NET Native toolchain. Since the package is compiled to native binaries, the package does not need to contain the .NET framework libraries. In addition, the package is dependent on the latest installed .NET Native runtime as opposed to the CoreCLR package. The .NET Native runtime on the device will always be compatible with your application package.

Local native compilation via the “Release” configuration will enable testing your application in an environment that is similar to what your customers will experience. It is important to test this on a regular basis as you proceed with development.

A good rule of thumb is to test your app this way periodically throughout development to make sure you identify and correct any issues that may come from the .NET Native compiler. There should be no issues in the majority of cases; however, there are still a few things that don’t play so nicely with .NET Native. Four+ dimensional arrays are one such example. Ultimately, your customers will be getting the .NET Native compiled version of your application, so it is always a good idea to test that version throughout development and before shipping.

In addition to making sure you test with .NET Native compilation, you may also notice that the AnyCPU build configuration has disappeared. With .NET Native brought into the mix, AnyCPU is no longer a valid build configuration because native compilation is architecture dependent. An additional consequence of this is that when you package your application, you should select all three architecture configurations (x86, x64 and ARM) to make sure your application is applicable to as many devices as possible. This is the Universal Windows Platform after all. By default, Visual Studio will guide you to this as shown in the diagram below.

Figure 1 – All three architectures are selected by default

With that said, you can still build AnyCPU libraries and DLLs to be referenced in your UWP app. These components will be compiled to architecture specific binaries based on the configuration of the project (.appx) consuming it.

The last substantial change to your workflow as a result of .NET Native is how you create a store acceptable package. One great feature of .NET Native is that the compiler is capable of being hosted in the cloud. When you build your Store package in Visual Studio, two packages are created – one .appxupload and one “test” .appx for sideloading. The .appxupload contains the MSIL binaries as well as an explicit reference to the version of the .NET Native toolchain your app consumes (referenced in the AppxManifest.xml). This package then goes to the Store and is compiled using the exact same version of the .NET Native toolchain. Since the compiler is cloud hosted, it can be iterated to fix bugs without you having to recompile your app locally.

Figure 2 – The .appxupload goes to the store; the Test folder contains the sideloading appx package

This has two consequential changes to the developer workflow. The first is that you as a developer no longer have access to the revision number of your application package (the fourth one). The Store reserves this number as a way to iterate on the app package if for any reason the package is recompiled in the cloud. Don’t worry though, you still have control of the other three numbers.

The second is that you have to be careful about which package you upload to the Store. Since the Store does the native compilation for you, you cannot upload the native binaries generated by the local .NET Native compiler. The Visual Studio workflow will guide you through this process so you select the right package.

Figure 3 – Select “Yes” to upload to the Store

When you use the app packaging wizard to create your packages, you should make sure to select “Yes” when Visual Studio prompts you to create a package to upload to the Store. I also recommend selecting “Always” for the “Generate app bundle” option as this will ultimately result in a single .appxupload file that will be ready for upload. For full guidance on creating a Store package, you can take a look at Packaging Universal Windows apps for Windows 10.

To summarize, the main changes to your workflow as a result of .NET Native are:

  • Test your application using the “Release” configuration regularly
  • Make sure to leave your revision package number as “0” – Visual Studio won’t let you change this, but make sure you don’t change it in a text editor
  • Only upload the .appxupload generated on package creation to the Store – if you upload the UWP .appx, the store will reject it with errors

Some other tips for utilizing .NET Native

If you find any issues that you suspect are caused by .NET Native, there is a technique you can use to help debug the issue. Release configurations by default optimize the code which loses some artifacts used for debugging. As a result, trying to debug a Release configuration can result in some issues. What you can do instead is to create a custom configuration and enable the .NET Native toolchain for that configuration. Make sure to not optimize code. More details about this can be found here.

Now that you know how to debug issues, wouldn’t it be better if you could avoid them from the get-go? The Microsoft.NETNative.Analyzer can be installed in your application via NuGet. From the Package Manager Console, you can install the package via the following command: “Install-Package Microsoft.NETNative.Analyzer”. At development time, this analyzer will give you warnings if your code is not compatible with the .NET Native compiler. There is a small section of the .NET surface that is not compatible, but for the majority of apps this will never be a problem.

If you are curious about the startup time improvements of your app from .NET Native, you can try measuring it for yourself.

Known issues and workarounds

There are a couple of things to keep in mind when using the Windows Application Certification Kit (WACK) to test your apps:

  1. When you run the WACK on a UWP app that did not go through this compilation process, you will get a not-so-trivial failure. It will look something like:
    • API ExecuteAssembly in uwphost.dll is not supported for this application type. App.exe calls this API.
    • API DllGetActivationFactory in uwphost.dll is not supported for this application type. App.exe has an export that forwards to this API.
    • API OpenSemaphore in ap-ms-win-core-synch-11-1-0.dll is not support for this application type. System.Threading.dll calls this API.
    • API CreateSemaphore in api-ms-win-core-kernel32-legacy-11-1-0.dll is not supported for this application type. System.Threading.dll calls this API.

    The fix is to make sure you are creating your packages properly, and running WACK on the right one. If you follow these packaging guidelines, you should never encounter this issue.

  2. .NET Native applications that use reflection may fail the Windows App Cert Kit (WACK) with a false reference to Windows.Networking.VpnTo fix this, in the rd.xml file in your solution explorer, add the following line and rebuild:
    <Namespace Name=”Windows.Networking.Vpn” Dynamic=”Excluded” Serialize=”Excluded” Browse=”Excluded” Activate=”Excluded” />

Closing thoughts

All Windows users will benefit from .NET Native. Managed apps in the Store will start and run faster. Developers will have the .NET development experience they are used to with Visual Studio, and customers get the performance boosts of native code. If you’d like to provide feedback, please reach out at UserVoice. If you have a bug to report, you can file it at Connect.

Engaging customers with Live Tiles and toast notifications (10 by 10)

Last week, we talked about how you can do three things to get your apps discovered and launched by Windows 10 customers. This week, we’d like to continue with how to increase customer engagement through some of the most loved features of Windows apps: Live Tiles and toast notifications.

If you’re already a Windows app developer, you are probably familiar with Live Tiles and toast notifications. If not, the increasing amount of Windows 10 customers is certainly a good motivator to start thinking about implementing them. Here’s what’s new:

  • Universal Action Center – After toast notifications are received, they now go into a system area called Action Center. With Windows 10, we’re bringing Action Center to Windows desktops, laptops and tablets, in addition to phones where it was already available. This means customers can get back to notifications they might have missed due to the transient nature of the initial toast and can interact with them in new ways.
    1_win10FullDesktop 2_win10mobileNotificationCenter
  • Adaptive and interactive toast notifications – Toast notifications across Windows devices can now display interactive UI, so customers can immediately provide input and take action. This means you can capture input, and even run app code, without pulling the customer from their current context. Toast notifications can also be enriched with images in addition to text.
  • Adaptive Live Tile templates – Content on Live Tiles can now be described using simple markup language, giving you full flexibility on how content is displayed on the Live Tile. Adaptive Live Tiles also adapt to different screen density devices, so you can ensure the Live Tile looks great on any device.
  • Improved secondary tile pinning behavior – Requesting to pin a secondary tile is now done without any customer or system interaction, so your app can immediately execute additional code after the tile is pinned. This also allows you to pin multiple tiles at once and send tile notifications to them immediately after pinning.
  • Synchronizing Live Tiles and toast notifications – A new type of background task trigger, called ToastNotificationHistoryChangedTrigger, allows background tasks to be triggered when the app’s notification collection is changed by anything other than the app itself. This means you can execute code when a customer dismisses notifications in Action Center, when notifications expire, or when new notifications are pushed through Windows Push Notification Services (WNS), making it easy to keep your Live Tile up –to date.
  • Badge unification – Last, but not least: Live Tile badges are now unified across devices, so the glyphs that were previously only available on Windows are now also available on devices running Windows 10 Mobile. This also ensures your Live Tile displays consistently across devices.

Let’s take a look at how to engage customers with new notifications and Live Tiles, making sure your app gets the usage it deserves.

Sending adaptive and interactive toast notifications

In Windows 10, toast notifications can be customized to display text, images and custom interactions. Previously, sending a toast notification meant choosing from the toast template catalog, which offered limited flexibility in appearance and no options for customer input. The sound that plays when the notification appears can also be easily customized. An example of this is shown below:

    <binding template="ToastGeneric">
      <text>This is a simple toast notification example</text>
      <image placement="AppLogoOverride" src="oneAlarm.png" />
    <action content="check" arguments="check" imageUri="check.png" />
    <action content="cancel" arguments="cancel" />
  <audio src="ms-winsoundevent:Notification.Reminder"/>


As mentioned, these interactive elements can be used to execute code through a background task in your app, to help customers stay in their current context while still interacting with your app. Start by declaring a new background task in the Package.appxmanifest, using the new Push notification type:


In the background task itself, you can now use the pre-defined arguments and user inputs as follows:

namespace Tasks
    public sealed class ToastHandlerTask : IBackgroundTask
        public void Run(IBackgroundTaskInstance taskInstance)
            //Retrieve and consume the pre-defined
            //arguments and user inputs here
            var details = taskInstance.TriggerDetails as NotificationActionTriggerDetails;
            var arguments = details.Arguments;
            var input = details.Input.Lookup("1");
            // ...

For more information on adaptive and interactive toast notifications, read the in-depth blog post from the team.

Implementing adaptive Live Tiles

Similar to toast notifications, Live Tiles in Windows 10 you now have the flexibility to visualize a tile through markup language. Previously this required selecting a tile template from the tile template catalog for prior versions of Windows. The adaptive nature of Live Tiles allows you to group content, so Windows can automatically adjust the amount of information shown on the Live Tile to the current device’s screen.

As an example, an app that displays e-mails on the Live Tile might display one e-mail message preview on the Live Tile on a small screen phone, but can display two e-mail message previews on larger screen phones simply by grouping the e-mails in the tile markup:

<binding template="TileWide" branding="nameAndLogo">
      <text hint-style="subtitle">Jennifer Parker</text>
      <text hint-style="captionSubtle">Photos from our trip</text>
      <text hint-style="captionSubtle">Check out these awesome photos I took while in New Zealand!</text>

  <text />

      <text hint-style="subtitle">Steve Bosniak</text>
      <text hint-style="captionSubtle">Build 2015 Dinner</text>
      <text hint-style="captionSubtle">Want to go out for dinner after Build tonight?</text>
Desktop Tablet High-Density Mobile
 7_desktopTile  8_TabletTIle  9_phoneTile

As seen in the above example, Live Tiles can now be fully defined in markup language, breaking away from the previously-needed pattern of generating an image (from XAML) and sending that to the Live Tile to display. For example, say you want a Live Tile that displays an image cropped to a circle with two large text labels below. You can simply define it like this:

<binding template="TileLarge" hint-textStacking="center">
    <subgroup hint-weight="1"/>
    <subgroup hint-weight="2">
      <image src="Assets/Apps/Hipstame/hipster.jpg" hint-crop="circle"/>
    <subgroup hint-weight="1"/>

  <text hint-style="title" hint-align="center">Hi,</text>
  <text hint-style="subtitleSubtle" hint-align="center">MasterHip</text>


For more information on adaptive Live Tiles and the new markup language, read the in-depth blog post from the team.

This week: spend some time on your app’s Live Tile to delight customers

Hopefully we’ve provided a quick, but comprehensive look at some of the improvements we’ve made to support you in engaging customers with Live Tiles and notifications in Windows 10. Our suggestion for the week:

  1. Think about how you can use the new Live Tile markup language in your app to create a beautiful Live Tile to delight customers
  2. If you display information on your Tile that can be grouped, make sure you utilize adaptive Live Tiles to cater to customers with high screen density devices
  3. Make use of the new interactive toast notification capabilities to expand your current notifications to provide additional information and support customer interaction

Be sure to head on over to DVLUP for the “It’s ALIVE!!!!!!” challenge, so you can claim points and XP for updating your apps, in addition to boosting customer engagement. Also, check out the full Windows 10 by 10 development series schedule for the 10 topics we have and will be covering in the series.

Finally, below you’ll find some additional resources to dive into this week’s topic. We’re looking forward to hearing what you’ll build via @WindowsDev and #Win10x10.

New Windows Microsoft advertising SDK with support for video interstitials

Today, Microsoft is releasing several important capabilities that allow you to increase ad revenue in your apps:

  • Microsoft Universal Ad Client SDK for Windows 10
  • Support for video interstitials on Windows 8.1, Windows Phone 8.1 and Windows 10, ideal for games
  • Ad mediation for Windows 8.1 and Windows 10 apps, to manage multiple ad SDKs and increase fill rate

If you have questions about the features mentioned in this blog, take a look at the more detailed Announcing the Microsoft Universal Ad Client SDK with support for video interstitial ads and ad mediation post from Microsoft Advertising.

Microsoft Universal Ad Client SDK for Windows 10

The Microsoft Universal Ad Client SDK is now available for Windows 10 devices. The ad SDK also supports Windows and Windows Phone 8.1 apps. The new ad SDK is built using native code and does not require .NET runtime, reducing the memory used and increasing performance. In addition, the new Ad SDK integrates several bug fixes and reduces the minimum refresh time to 30 seconds (previously it was 60 seconds when the app was running in metered networks).

To use the SDK, install the new ad SDK, then drag and drop the control, and configure it.

Support for video interstitials

Today we are releasing the capability to display video interstitials through the Microsoft Universal Ad Client SDK. Video ads are a highly popular way of monetizing apps and games, and can offer higher eCPM than banner ads. Video Ads are supported in Windows 10, Windows 8.1 and Windows Phone 8.1 through the Microsoft Universal Ad Client SDK released today.

Read the instructions on how to use video interstitials to get started.

Ad mediation for Windows 8.1 and Windows 10 apps, enhancements for Windows Phone

Dev Center has supported ad mediation for Windows Phone apps for some time now, allowing you to manage multiple ad SDKs from different providers to achieve up to a 99% fill rate, thus increasing the ad revenue in your apps. Enabling ad mediation is easy, just add the Windows ad mediation SDK to an app and submit it to the Store. You can then managing multiple ad networks without having to modify the app code or resubmit the app for certification.

Today’s release adds:


With the new release, you have the same capabilities and reports provided previously for Windows Phone ad mediation, such as tracking fill rate for each ad network and users by configuration. Ad mediation is supported by both Visual Studio 2015 and Visual Studio 2013, and supports Windows 8.1, Windows Phone 8.x, and Windows 10 UWP apps.

To try out ad mediation, follow the steps described in the documentation. I also recommend reading the best practices to help you get started.  All these new capabilities are detailed in the Announcing the Microsoft Universal Ad Client SDK with support for video interstitial ads and ad mediation post from Microsoft Advertising.

As we continue to roll out new features and tools for Dev Center, please let us know if there are any issues (through support) or new features you’d like to see included in future releases (through user voice).

Contextual sensing in Windows 10

This blog was written by Rinku Sreedhar, Senior Program Manager

In Windows 10, we are very excited to introduce several APIs for contextual sensing that can help you build apps to improve your customers’ daily lives. These include apps that detect presence when customers approach their devices, apps that can detect whether your customer is walking or driving, apps that can help customers track their fitness routines, and more. Using these APIs you can anticipate customers’ needs and proactively deliver targeted, personalized, and relevant content or services to enhance and simplify their lives. It is very powerful both in Consumer and Enterprise scenarios.


Detecting activities

We are very happy to introduce the new Activity Detection APIs, which will help detect the user’s motion context. These APIs attempt to detect activity states based on current motion of your customer, such as Walking, Running, In Vehicle, Biking, Stationary, and Idle. The Stationary state is returned when a user has the device with them, while the Idle state is returned when the user has the device laying idle on a table or still surface. You also have the ability to create background triggers and get history details for up to 30 days.

A few usage scenarios are:

  • Surface information based on the user’s motion context (such as an activity-based playlist)
  • Change the app behavior based on the user’s motion context (such as auto-adjusting the camera focus when you detect that the user is capturing an image while walking or running)
  • Health and fitness tracking
  • Navigation and maps
  • Power saving (fpr example, avoiding constantly polling location or wifi when the device os idle or stationary)

The API pattern is shown below:

// Getting the current activity
var reading = await activitySensor.GetCurrentReadingAsync();

// Subscribing to activity changes
activitySensor.ReadingChanged += new TypedEventHandler<ActivitySensor,

// Getting history of up to 30 days
DateTimeOffset yesterday = ...
var history = await ActivitySensor.GetSystemHistoryAsync(yesterday);
foreach (var entry in history) { ... }

// Using a background task
var trigger = new

// .. register the trigger, etc..

More detailed API reference for activity detection can be found here and UWP SDK Samples can be found here.

Counting steps

Another new addition is the pedometer which counts the user’s steps both when walking and running. As with activity detection, you can access history details for up to 30 days.

A typical application would be health and fitness tracking (without requiring an additional gadget/ wearable device). The pedometer can also combine with the wearable and Windows device sensor data.

The API pattern is shown below:

//Getting the pedometer reading changes
pedometer.ReadingChanged += new TypedEventHandler<Pedometer,

void ReadingChanged(Pedometer sender, PedometerReadingChangedEventArgs args)
    PedometerReading reading = args.Reading;
    if (reading.StepKind == PedometerStepKind.Walking)
        walkingSteps = reading.CumulativeSteps;

//Getting pedometer step count history
var history = await Pedometer.GetSystemHistoryAsync(yesterday);

More detailed API reference for edometer can be found here and UWP SDK Samples can be found here.

Barometer and altitude sensing

We are very happy to introduce the Barometer API that reports barometric station pressure, and the Altimeter API to report altitude and changes in elevation.

Typical applications include:

  • Health and fitness tracking: knowing the altitude, you can determine if the user is going up or down and adjust calorie expenditure calculations accordingly
  • Detect what floor the user is on for indoor navigation
  • Weather forecasting

The API pattern is shown below:

Barometer barometer = Barometer.GetDefault();
BarometerReading reading = barometer.GetCurrentReading();

double pressure = reading.StationPressureInHectopascals;
barometer.ReadingChanged += ...

Altimeter altimeter = Altimeter.GetDefault();
AltimeterReading altimeterReading = altimeter.GetCurrentReading();

double altitudeChange = altimeterReading.AltitudeChangeInMeters;
altimeter.ReadingChanged += ...

//Selecting a report interval
mySensor.ReportInterval = 500;

Detailed API reference for Barometer can be found here and UWP SDK Samples can be found here. Detailed API reference for Altimeter can be found here and UWP SDK Samples can be found here.

Detecting presence

We now support APIs for both short range and long range presence detection. Short range sensors can detect for up to 2-3cm, while some of the longer presence sensors can detect presence up to a 12 meter range.

A few usage scenarios are:

  • Enabling a device to wake on user approach or log off when the user has departed. The Surface Hub uses these APIs to wake on approach when a user walks into a conference room and log off when they depart.
  • Automatic turn off of the display during a phone call
  • Understand and ignore accidental clicks when it is detected that the device is in the user’s pocket
  • Detection of gestures

The API pattern using Proximity is as shown below:

using Windows.Devices.Sensors;

//Getting the current reading
ProximitySensorReading reading = sensor.GetCurrentReading();
bool isDetected = reading.IsDetected;

//Subscribing to reading changes
sensor.ReadingChanged += ReadingChanged;
void ReadingChanged(ProximitySensor s, ProximitySensorReadingChangedEventArgs e)
    ProximitySensorReading reading = e.Reading;
    bool isDetected = reading.isDetected

//Selecting a report interval
mySensor.ReportInterval = 500;

More detailed API reference for Proximity can be found here and UWP SDK Samples can be found here.

Stay tuned; we will be sharing more details of new Windows 10 features upcoming blog posts. You can also find more information in our Build 2015 session on building contextually-aware UWP apps using sensors.

Getting noticed and installed more often (10 by 10)

Welcome to the first week of our Windows 10 by 10 series. To kick things off, let’s begin where your customer engagement starts – with the Windows Store.

To help ensure that your apps are getting discovered and launched by Windows 10 customers, here are three steps to take now:

  1. Update your Store listing to increase your chances of being installed.
  2. Establish a usage baseline using Visual Studio Application Insights and the new app usage report.
  3. Learn how to use the Windows Store’s new campaign tracking capabilities to measure success.

Even spending just an hour this week will not only help you put your best foot forward with Windows 10 customers, but it will also help you establish a strong baseline to measure success against as you evolve and improve your app.

Give your Store listing a makeover

So let’s begin with your Windows Store listing, where customers spend a brief moment looking at your pitch to determine whether they click a button to install your Windows app and give you a chance. This is one of the first touch points you’ll have with your customer.

Make your app easier to get discovered by customers

startMenu_10x10week1To properly show up in Store searches, you’ll want to be sure you’re following our keyword recommendations: you can use up to 8 keywords, and you should only use the ones that genuinely describe your app. If you’re not Facebook or Twitter, don’t waste a keyword implying you are.

We’ve also integrated Store listings into more of the Windows experience, helping customers discover the apps and games that are relevant to them for the task at hand. For example, searching using Cortana not only returns local apps and documents, but it also includes relevant results from the Windows Store and the web – helping you get discovered by the growing number of Windows 10 customers worldwide. Keep these searches in mind when determining which keywords make sense for your app.

Also, we highly recommend that you submit promotional artwork as part of your Store listing – these are images that can be used to promote your app in a number of places if and when the app is featured. Unless your app has these images, the Windows Store can’t feature your app – no matter how awesome it is. With Windows 10, we added a new 2400×1200 image, which the promotions team will use in a number of places, most notably as a hero image in the Windows Store “Spotlight” section. If you want to be considered for promotion, take some time this week and submit the promotional artwork, especially the 2400×1200 size. And while your mind is on the topic, it’s worth reviewing the other Windows Store requirements for promotional consideration. It’s important to stress that while submitting these images and ensuring you meet promotional consideration requirements doesn’t guarantee you a promotion spot; not meeting the requirements does guarantee that you won’t be considered.

Make your app compelling to install

Okay! So you’ve gotten a prospective customer’s attention and you’ve gotten them to your app listing in the Store – what will they see when they get there?

Your Store listing page is the first way most of your potential customers get to know your app, and where they decide whether or not they’ll install it; it’s your sales pitch to the world – your proverbial book cover. Without visually communicating what you have to offer, along with a few words to hook your potential customers, they’re likely to continue on past your app and onto someone else’s.


Surprisingly, many developers give the least amount of thought to their apps’ Store listings. To prepare for new customers discovering your app for the first time, now is a great time to revisit your listing and apply some evergreen advice:

  • App descriptions should explain the benefits in the first couple sentences. The Store naturally truncates the listing and only shows the first couple lines (take a look at the Remote Desktop listing above as an illustrative example). Be sure your most compelling statement/pitch shows up above the break, so that customers are interested in seeing more.
  • Keep your screenshots interesting and compelling – particularly your first one (don’t just use your title screen). Ensure that the images properly represent your app or game, and don’t be afraid to mark up the images with text to better explain what they’re looking at. Find a tool to help you create quality screenshots and images. From the donation-supported Paint.net and GIMP programs, to the larger budget Adobe products, there are many options to fit your skills and needs.
  • If your app is localized for multiple markets, ensure that your screenshots and descriptions are localized as well. (And, as a pro tip, if you’re a published Windows developer and you’re considering localizing for other markets, be sure to check out your Dev Center Benefits for some serious price breaks on localization services from Lionbridge.)

Similar to the lack of promotional images, it’s staggering how many apps in the Store have been passed up for being featured because they didn’t have an adequate app description, or had screenshots that were simply their title screen. Don’t let this happen to you!

Start measuring your success

Now that you’ve cleaned up your Store listing page and encouraged new customers to give your app or game a try, let’s examine a few ways to determine if your pitch is landing. The Windows Dev Center recently made some serious advances on the integrated reporting capabilities, let’s dig into two of them – the app usage report and the upcoming campaign tracking feature.

The Usage report provides a detailed breakdown of how your app is being used, and by whom. If you log into your Dashboard and take a look at the report today, most of you will notice that it’s currently blank, and that it prompts you to start using the Visual Studio Application Insights SDK in your app. For those of you not familiar with Application Insights, the service collects telemetry data from your app and uses Azure to store [at no cost] and present it. The Windows Dev Center can access this telemetry data to provide you with a view into how customers are using your app.

You can use Visual Studio 2015 or 2013 to add Application Insights to your app in about 10 minutes. To get started, open up your Windows app (Windows 8 or 10 – client or phone), and do the following:

  1. addAppInsight_10x10week1Right click on your project in Visual Studio and select ‘Add Application Insights Telemetry…’
  2. Application Insights will then launch a wizard that walks you through adding the service into your Windows app. As part of this process, it will ask you where you want to keep your data (if you don’t already have a free Azure account, you’ll need to create one).
  3. Once you’re done with the wizard, it will set up and configure your project for telemetry collection.


At this point, you’ll be able to see on Azure, in near real-time, how many folks are using your app in the wild. This telemetry can tell you a lot about your app and where to direct your development efforts – you can measure what features are being used, by how many people, and for how long.

And once you publish your app into the Store and enable the app usage telemetry setting on the Windows Dev Center dashboard (under ‘Account settings’), the data will be visible on the Usage report.

You can then use the TelemetryClient class to gather additional telemetry data like page views (or even pivot/hub control activity), interesting events you want tracked, and exceptions. Beyond the basic page telemetry you get by using Application Insights, you can taking advantage of exception tracking to get a near real-time view into trouble spots (particularly useful when launching an update to the public). To track exceptions, use the following code:

    // ...
catch (Exception ex)
   private TelemetryClient telemetry = new TelemetryClient();

As you get more comfortable with analytics, you can start instrumenting all kinds of things. For example, this sample code tracks how long it takes to accomplish a task:

var stopwatch = System.Diagnostics.Stopwatch.StartNew();
// ... perform the timed action ...
var metrics = new Dictionary <string, double>
   {{"processingTime", stopwatch.Elapsed.TotalMilliseconds}};
// Set up some properties:
var properties = new Dictionary <string, string>
   {{"signalSource", currentSignalSource.Name}};
// Send the event:
private TelemetryClient telemetry = new TelemetryClient();
telemetry.TrackEvent("SignalProcessed", properties, metrics);

For my personal app (which is very web service dependent), I found it very useful to understand where web service calls were leading to bad reviews, and what countries were having the most issues. Over time, as I tried a few different mitigation approaches (service error handling, caching, etc.), I used my telemetry data to increase customer engagement (which I measured by time spent in app) and overall customer satisfaction (app rating improvements in specific regions) to measure success of my approach.

For more information on advanced app telemetry, check out a blog post from the engineering team on the topic last year, written by Kraig Brockschmidt. (Note that when this post was written, we were still developing Application Insights. Now that it’s available, instrumentation is much easier!)

Start promoting yourself

With a baseline understanding of your customers, it’s time to start turning the crank and driving traffic into your app. To do this, let’s look at three really cool ways that the Windows Store helps you to experiment with app promotion:

  • Start running campaigns for your app, and using the campaign tracking feature (being rolled out to developers this month) to understand which campaign is bringing in more customers.
  • Work with affiliates in the new Microsoft Affiliate Program, which provides a new way for referrers to earn a 7% commission on all new purchases via the Windows Store.
  • The Windows Dev Center makes it easier to commission promotional ad campaigns.

Understanding promotion success

Taking advantage of the campaign tracking feature is perhaps the easiest way to understand where new customers are coming from. You can use these much as you might already be using URL redirect services (such as bit.ly) to track traffic patterns with your users:

  1. Append a ‘campaign’ tracking ID to the end of your app’s Store listing URL (which can be found on the App Management section of your app’s App Identity Page in the Dev Center dashboard). The tracking ID is a simple string and can be whatever makes sense to you for tracking purposes.
  2. Start using these URLs, complete with campaign IDs appended to the end of the name, wherever you point to your app in the format https://www.microsoft.com/store/apps/yourAppName/yourAppProductID?cid=yourCampaignID. As an example, let’s say you’re Skype (with a Product ID of 9wzdncrfj364) and you want to promote the app on a variety of channels. You might use the following three campaigns:
    1. Return to the Channels and conversions report on your Windows Dev Center dashboard and view the results (see the sample report below):


    Note: the Channels and conversions report is being made available to all developers over the next few weeks.

    Another interesting data point collected is whether or not the campaign ‘converted’ the customer. The report will track whether or not a customer purchased the app (or an IAP) within the 24-hour period after they followed the link, based on the Microsoft Account the customer was signed in with at the time they followed the link.

    Once you update your app to a UWP app for Windows 10, you can further take advantage of the campaign tracking feature by using the CurrentApp.getAppPurchaseCampaignIdAsync() method to determine, at runtime, whether a campaign led a customer to your app (and, if so, which one). You can even tailor the app or game experience to better fit the channel they came from – providing you with the potential to run offers through different partners, and light up specific in-app offers when customers arrive via a particular partner.

    Sign up as an affiliate

    In addition to making it easier to understand where your customers are coming from, we are investing in many new ways to help new customers discover the Store, including an expansion of the Microsoft Affiliate Program to include everything in the Windows Store – apps, games, music, videos, and more.

    The program makes it easy for any partners to earn commissions by promoting Windows Store content. The infrastructure of the affiliate program works in the same way as the campaign tracking feature, except it’s packaged up for third-parties to easily drive traffic to your app through the Windows Store and earn commission on referred purchases. Affiliates can earn a 7% commission on all paid purchases made within the 24 hours, in-app purchases made within 14 days and monthly recurring subscriptions up to 6 months.

    If you do app or game reviews on your site or blog (or even via Twitter), I definitely advise that you sign up for the affiliate program and use affiliate links wherever you refer folks into the Windows Store.

    Promote your app with ads

    Lastly, we continue to make it easier to get your app in front of more customers by creating ad campaigns for your app. Using the ‘Promote your app’ section of the Windows Dev Center, you can create and run one of two types of ads:

    • Pay to run an ad that runs in other apps, targeting your desired device family and app category
    • Run free ‘house ads’ within your other apps, for a device that doesn’t already have your app or game installed on it

    Once launched, you can use the App install ads report to measure how your ad campaigns are performing (tracking the generated impressions, clicks, and installs for each campaign), and adjust your promotion strategy accordingly.

    This week: Spend an hour with your app’s Store listing

    We hope that you enjoyed our kick-off blog post for the Windows 10 by 10 series. For the next nine weeks, we’ll be focusing on what you can do with your app on Windows 10 to drive customer engagement.

    But before you crack open your app, we encourage you to spend an hour on your app’s Store listing this week:

    1. Take 20 minutes to revisit your app description and give it a makeover
    2. Take 20 minutes to update your screenshots and add a 2400×1200 promotional image
    3. Finally, revisit how you link to your app and start using campaign IDs to track where your Store installs are coming from

    And the next time you update your app, we highly recommend that you add in Application Insights. It’s truly enlightening to see how customers use your app, and even better watching near real-time telemetry (particularly for handled exceptions and app crashes) when you launch a new app update.

    As always, keep in touch and let us know what you think below or via @WindowsDev. All this week, the conversation about app promotion takes to Twitter using the hashtag #Win10x10 – whether you have app telemetry pro tips, or just want to highlight what’s worked for you around app promotion, definitely share it with the community.