Add Link to Rating Feature in Windows UWP App

In oder to add a link to rate your app following code can be used in javascript UWP app var storeID = ‘xxxxxxxxxxxx’; function rate() { var uri = new Windows.Foundation.Uri(“ms-windows-store://review/?ProductId=” + storeID); var options = new Windows.System.LauncherOptions(); Windows.System.Launcher.launchUriAsync(uri, options); } Replace storeID with your app’s Store ID and call “rate” method on a button click event which will open the app in windows store with rate popup overlay.

App Promotion Trick for Windows Store App

If you are a publisher who has published multiple UWP apps in the windows store and want to add a catalog of all your other apps in your UWP app, then there is no need to write a lot of code to achieve this capability. Microsoft has provided URI scheme to launch the Microsoft Store app to specific pages in the store. We can use search capability to find products from a specific publisher and simply launch that URI using LaunchUriAsync API method. For ex. in order to launch all products published by some “XYZ Corporation” in the windows store we can simply call the following URI ms-windows-store://publisher/?name=XYZ Corporation Following code example demonstrates how this can be achieved using 3 lines of code in Javascript store app function showPublisherApps() { var publisherDisplayName = “Microsoft Corporation”; // Change this to your publisher name var uri = new Windows.Foundation.Uri(“ms-windows-store://publisher/?name=” + publisherDisplayName); var options = new[…]

Open Share Dialog from Universal Windows Javascript App (UWP)

Opening Share Dialog Popup in Windows Universal App is very simple and with a few lines of code, this functionality can be quickly added to any app. The code below can be used to share an app’s web URL (you can use MS Store URL of the app as well) in UWP Javascript application var page = WinJS.UI.Pages.define(“/index.html”, { ready: function (element, options) { var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView(); dataTransferManager.addEventListener(“datarequested”, dataRequested); }, unload: function () { var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView(); dataTransferManager.removeEventListener(“datarequested”, dataRequested); } }); function dataRequested(e) { var request = e.request; var storeID = ‘xxxxxxxxxxxx’; request.data.properties.title = “Your title”; request.data.properties.description = “App description”; request.data.setWebLink(new Windows.Foundation.Uri(“https://www.microsoft.com/store/apps/” + storeID)); } function showShareUI() { Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI(); } In the application page ready event we need to initialize DataTransferManager and attach an event listener for “datarequested”. In that method you can set title, display, web link properties which will be used by the dialog popup. Store ID[…]

Force Windows Store App to Full Screen Mode

In order to launch windows store app to full screen mode, check out the code here. Once app is launched in full screen mode, it can be resized by user by using the resize option which is available in all app windows and can not be removed. For windows pc, we can capture window resize event and try to enter full screen again which in effect doesn’t let user resize the application window. The java script code for achieving this: var page = WinJS.UI.Pages.define(“/index.html”, { ready: function (element, options) { // Add event for window resize event window.addEventListener(“resize”, onResizeView); } }); function onResizeView() { // Whenever window is resized, enter it to full screen mode var ViewManagement = Windows.UI.ViewManagement; var ApplicationView = ViewManagement.ApplicationView; var view = ApplicationView.getForCurrentView(); view.tryEnterFullScreenMode(); }  

Launch External Url in Browser from Windows Store App

The java script code for achieving this: // Create a Uri object from a URI string var uri = new Windows.Foundation.Uri(“http://test.com”); var options = new Windows.System.LauncherOptions(); // Launch the URI with a warning prompt options.treatAsUntrusted = true; // Launch the URI Windows.System.Launcher.launchUriAsync(uri, options).then( function (success) { if (success) { // URI launched } else { // URI launch failed } });  

Windows 10 App :Host Defined Policy: Inline Script. Resource will be blocked.

I recently ported one of my java script projects to Windows store app and got the error as following CSP14321: Resource violated directive ‘script-src ms-appx: ‘unsafe-eval’ blob:’ in Host Defined Policy: inline script, in ms-appx://13bdc914-5111-4c95-a5e6-82029c5105ec/index.html at line 21 column 12. Resource will be blocked. If you have something like the following, it won’t work <a href=”javascript:void(0)” id=”somelink” onclick=”callMethod();”>Link</a> Since I was using jQuery in the project, I simply used jQuery to bind click event to the element $(“#somelink”).click(function () { callMethod(); }); and Voila, everything works but I had many pages which had this reference and I had to make this change to all pages. After some research I found that there is an alternate way which is much faster to change. By default ms-appx:/// protocol is used in store apps to fetch the content. For web apps specify a specific protocal ms-appx-web which is then used for the app. This can be done[…]

Force Windows 10 Store App to Open in Full Screen Mode

The java script code for achieving this: (function () { “use strict”; var app = WinJS.Application; var activation = Windows.ApplicationModel.Activation; var ViewManagement = Windows.UI.ViewManagement; var ApplicationViewWindowingMode = ViewManagement.ApplicationViewWindowingMode; var ApplicationView = ViewManagement.ApplicationView; app.onactivated = function (args) { if (args.detail.kind === activation.ActivationKind.launch) { if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) { // TODO: This application has been newly launched. Initialize your application here. } else { // TODO: This application was suspended and then terminated. // To create a smooth user experience, restore application state here so that it looks like the app never stopped running. } args.setPromise(WinJS.UI.processAll()); ApplicationView.preferredLaunchWindowingMode = ApplicationViewWindowingMode.fullScreen; } }; app.oncheckpoint = function (args) { // TODO: This application is about to be suspended. Save any state that needs to persist across suspensions here. // You might use the WinJS.Application.sessionState object, which is automatically saved and restored across suspension. // If you need to complete an asynchronous operation before your application[…]

Monetize Windows 10 Store App with Ads

In the previous article we converted our Phaser game to a windows 10 store app (UWP app). Now we all want to monetize our games. One way of monetizing is by putting ads in our game. Micorsoft has built support for ads in the UWP which offers various ad types and also supports mediation with other ad networks. Refer to following resources to get more detail https://developer.microsoft.com/en-us/store/monetize/ads-in-apps We will go through steps to quickly add a banner ad to our game. First step is to add WinJS and Microssoft Advertising SDK to our visual studio project. Open proejct and go to NuGet Package Manager -> Manage NuGet Packages for Solution Search for WinJS in Browse section, select the package and click install which will install the package in the current solution. Accept the popup confirmations if you get any. Next we will add Microssoft Advertising SDK. Simply browse for Advertising and in the results[…]

Compile Phaser Game to WIndows 10 Store App

In previous articles we started building an Android mobile app using Phaser. Check out the articles – Introduction, Calculation, Game Screen, FPS Problem Now since windows has native support for javascript and HTML5, it makes sense to distribute our Phaser games to windows app store to reach new audience. The steps required to compile Phaser game to Windows 10 App is pretty straight forward with no need  for any change in the code. You would need windows 10 to develop and debug the application. If you do not have windows 10 yet, go and download evaluation version of windows and install it in a VM. Microsoft is also providing evaluation version of readymade VMs supporting various technologies such as VMWare, HyperV, Parallels etc which comes pre-loaded with development tools such as Visual Studio 2017 Community edition which you can try for evaluation. https://developer.microsoft.com/en-us/windows/downloads/virtual-machines If you already have windows 10 then download and install[…]