Blog of Web Developer Garry Pilkington

(ASP.Net, C#, AngularJs, JavaScript, HTML5 & UWP)

I am working on an app for the Windows Store that requires mapping functionality. As it is a Windows app, it seems logical to use Bing Maps as they also provide an SDK for apps. Currently it is at version 8, but I had a few problems implementing that version so went for version 7 with the hope to upgrade it at some point when I get more traction for the app.

Click on the Create Key link and enter some details about the app. For store apps, a key type of Basic should suffice as we are not doing any enterprise level development. Choose Universal Windows app for the type and any URL you have for your in dev app (I use a placeholder page on my website where the app privacy policy etc. are going to go).

Some transactions with the Bing Maps API are billable, but you have to exceed a limit of 50,000 transactions in any 24 hour period, a listing of billable transactions can be found here. The reason I am mentioning this is in case you are offering a free app and a large number of users start to hit the service you could be liable to paying out.

While there have a look at the feature set for V7 with the online examples. As these are all HTML and JavaScript based samples, they are also ideal for a WinJS UWP app.

So now when we expand the References in our app we can see the required files for the mapping functionality we are going to build with.

I like to structure my apps, so that the main entry view (index.html and main.js) do a check on load and change the view depending on screen size/device etc. So I create a home view which has the ready, unload and updateLayout functionality. This home view is then loaded from the main entry view and inserted into a content host element.

We now need to add the script references and an element for the map in the home.html file:-

The CSP is important because it defines which urls are safe to load from. The div with the id webview is where our map will go.

Then in the home.js file add this

There you go, our simple map in the app.

There is so much more functionality that can ne added to this app such as getting the geolocation of the user and adding pushpins to different locations, but I will leave that for another post.

If you want to monetize your UWP apps, it might be part of you plan to have some kind of trial so that uses can try out the basic functionality of your hard work. This can be achieved in two places, firstly you need to test and set the properties in the app. Then you need to change the properties of your app submission in the Windows Dev Center. So here I will cover how we write the code to test for a trial installation of your app.

In my MoonPhase app, I have limited some functionality in the trial version. Basically a user can view the current details on the Moon, but if they want to move forward or backwards in time to see what the Moon looks like on different days, then a message popups up to tell them they cannot do that in the trial. This way they get to use the basic functionality and if they find the app useful, then they can pay for the full version in the app store.

Trial Functionality in UWP

So here is the logic I have in the JavaScript for the view

The ‘message’ element is a div in the HTML that the fly out will append to when the ‘previous’ button is clicked.

In the JavaScript listing above there is a call to getLicenseInfo(), this function takes in a Boolean that if set to true then it is in trial mode and needs to use the CurrentAppSimulator as opposed to the CurrentApp. The CurrentAppSimulator does just that, it simulates certain properties of the application that you have control over.

So to test locally simply pass in true.

var licenseInformation = getLicenseInfo(true);

The CurrentAppSimulator will then look for the WindowsStoreProxy.xml file that resides on your drive, usually somewhere like this:-

Depending on what you are testing for, you can populate the sections you need. I am testing for a trail version, so set the IsTrial within the App element to true. You can now run the app in the debugger and you can step through your code to see what paths it is taking. In my case I show the message fly out notifying the user of the trial status.

One thing to remember though is to take out the Boolean or set to false before submitting to the store. I am still looking for a better way to handle this and was hoping there would be some sort of pre-processor functionality like what is used in C# that could be switched when in debug mode.

Submitting Through the Windows Dev Center

So once you are happy to publish the app and the Boolean has been taken out or set correctly, go to the ‘Pricing and availability’ section of your submission.

The use the drop down to set the trial period.

When a user first installs the app in trial mode the real IsTrial property will be set to true and each time the app launches it will check the install date and if this is still set to true then the app won’t launch and the user will be presented with a Windows dialog to prompt them to purchase from the store. When they do purchase, then the IsTrial is set to false and they get all the functionality.

I am posting this here as somebody else thinking of creating store apps for Windows 10 might thing it interesting. I intend on following this post up with another about app promotion techniques.

App Statistics

Once you have an app published in the Windows Store, you can get to a wealth of information about which markets, demographics and devices are the most popular. This is in the form of in browser views, but you can also download the raw statistics for analysis using Excel for example as I have done here.

I have 5 apps in the store currently, but I am only going to concentrate on 3. MoonPhase is the oldest and has been in the store since Windows 8 was first released. It has over 6000 downloads to date and has recently been migrated to a Windows 10 UWP app. It was originally free, but I started changing for it a couple of months ago. I don’t make a huge amount of money from this app, but its better than nothing.

Looking at the past 30 days acquisitions and usage, the United States comes at the top of both with UK second.

Next is WebUp, this is another paid app which is just under two months old. It is aimed at the enterprise market sector that is responsible for web site monitoring, whether that be corporate intranets or public facing web sites.

These stats are a bit strange as they show United States download more, but the UK use the app more. Is there something stopping the US from using the app more after they have paid for it?

Both MoonPhase and WebUp show that the United States are quite happy to spend money in the store even if they don’t get the full use out of the software. The UK looks like they are better at getting more bang from their buck (or pound). WebUp is more expensive than MoonPhase which might be the reason the UK is lower in acquisition rates. I am about to run an experiment where both apps will be priced much lower and I will see if the price is forming a barrier to UK acquisition rates.

Thirdly is GetWalking. This is a free app aimed at the personal health sector, it is a simple pedometer that measures both distance walked and steps taken. It is the youngest of the 3 apps as it has only been in the store less than a month. I do intend on monetizing this app, possibly through advertisements, but not entirely sure yet. There are more features I wish to add, but currently I am just getting some stats in an MVP kind of way.

The chart shows that the UK has both the highest acquisition and usage, again with the US second in acquisitions, but strangely China overtakes it with usage. It seems that the Chinese market get more use out of this app than the US.

Interestingly all three app show that both the US and UK are either at the top or near the top of the charts in acquisition and usage. I am a UK based developer and these apps are published in all the markets that Microsoft allow, so I was expecting there to be more numbers from markets such as India and China. Is it a language thing perhaps?

Also very strange that an app can be used in the United Arab Emirates, but never acquired from there. Does this show that app statistics are not entirely tied to a users country of origin (Windows account country registration)?

None of these app have undergone any app promotional exercises except I have blogged about MoonPhase and WebUp. The Windows Store statistics show that all 3 of these apps get views from users coming to the store and searching not from outside search engines or sites such as Google/Bing or any of my previous posts (except for a handful, not worth bothering with).

WebUp is a new website monitoring tool that can also be configured for other endpoints such as web API urls. It is live in the Windows store as a UWP app, which means it can run on mobile, desktop, tablet and Xbox.

Why UWP?

The Microsoft ecosphere for app development, although on the mobile side is way behind both iOS and Android, has huge potential with everybody who runs Windows 10 included no matter what device. Here are some of the reasons I chose to publish on the Windows app store.

Auto updating

Any change I wish to make to the app once gone through certification will auto update on the end users machine leaving them with an always up to date version with no user input. Gone are the days when a new version of an application comes out, you got to go to the site, download and then install it.

No credit card information collected

WebUp is free for a trial of 7 days, but some of the features are locked out until upgraded to the full version. This payment process is entirely handled by Microsoft and although there are payment methods out there such as Stripe, as a developer I don’t need to lift a finger, just specify the price.

Runs across multiple devices

UWP apps are compiled once, but each architecture is included which means once a package is uploaded to the Windows Store, it is available for any Windows 10 device. WebUp gives a great experience on a tablet sized machine, but some users are running it on an Xbox with a massive display and using it as an information radiator. The mobile version is great when you need to whip out your phone and just check the status of your web sites.

User can multi install

The Windows Store allows a single user to install the app on up to 10 devices giving them the freedom to run it in multiple locations on different devices. WebUp can be installed on Xbox for an information radiator but you can also have it running elsewhere in an organisation with a different subset of http end points showing. A manager can also have it on their mobile device connected to the local Wi-Fi giving them satisfaction that everything is running fine.

Don’t need to worry about account management

With more traditional web based monitoring solutions, username and passwords need to be configured to log into the service, with a UWP Windows app, the installation is linked to the Microsoft account of the user so no more little yellow notes with credentials stuck to the monitor.

Can be installed inside enterprise and behind corporate firewall

As the app is installed to the device and not hosted by a third party such as SaaS providers, no holes need to be punched through the firewall if all your http end points are internal.

So those are some of the reasons I opted for UWP, it is early days at the moment, but I am already getting some traction and have other features in mind for the app.

I have just released an update to one of my UWP apps called WebUp. The additional functionality I added was email notifications when a http end point went offline. There are different ways you can message from a UWP app, but I wanted to use SendGrid to manage all messaging, so in this post I will cover adding this functionality from a UWP app written using WinJS. So yes it is possible to consume C# functionality from JavaScript and it is easier than you think. Why SendGrid you may ask, simply that they allow you to send 12 thousand emails per month for free, can’t grumble with that.

Windows Runtime Component

This is a dll that can produce winmd metadata that can then be consumed by UWP app written in any supported language such as C#, C++ and even JavaScript. Although the functionality can be limited somewhat, they can be used to create wrappers around libraries that cannot usually be accessed in a UWP app.

What is WinJS?

This is a JavaScript framework from Microsoft that can allow the developer to quickly add functionality to UWP apps. Although originally developed just for creating Windows Store apps, more recently this library has been open sourced and can be used as a framework to create web applications. It can still be used however to create UWP apps using the JavaScript template in Visual Studio.

Creating the app

Firstly create an app using the basic WinJS template in Visual Studio.

Choose the target and minimum versions.

Now a new project is needed to be added to the solution, so right click the solution.

Choose Windows Runtime Component under the C# collection.

Right click the references of your main UWP project and add this component.

Although it’s easy to add references via NuGet, for some reason with UWP apps created this way, the library was not copied locally, so I cloned the repo from GitHub and built the project locally giving me a nice shiny library I can then reference old school.

Just make sure it is set to copy local in its properties.

Now for some code.

In the class code auto generated when you created the Runtime Component, make sure you have the using statement for LightBuzz.SMTP and add this code:-

When using SendGrid, you can add extra credentials to your account that helps separate out different usage scenarios. I have credentials set up for my WebUp app and I have used it here, just swap out with your credentials.

While in the Component code, have a look at the project.json file, it will list all the runtimes that are available for the component. When running this app,, you will need to change the environment to one of these as ‘Any CPU’ does not work.

Now back in the UWP code, add something like this to the app.onactivated function; obviously you will want to put it somewhere else, but for this example it will work.

Enter your email address and run the app. With any luck you should start to receive emails direct from your app via SendGrid.