Search code examples
winjscordova-plugins

How to target WP8.0 using VS2013, using Navigator from WinJS and BarcodeScanner from Cordova


I am puzzled. I am getting my hands on Windows Phone development. I want to develop a Cordova Javascript Application that includes barcode scanning. I have found this plugin: https://github.com/wildabeast/BarcodeScanner

This plugin doesn't work with WP 8.1 so I am targetting Windows Phones 8 using VS2013. I wanted to use WinJS and its Navigator control so I started with the Cordova template and copied code from a WP 8.1 Navigation template but this one has reference to "Microsoft.Phone.WinJS.2.1, Version=1.0", I understand that this reference makes possible to use this HTML: data-win-control="Application.PageControlNavigator"

It doesn't work in my project as I haven't found such reference to include so my App is working but I am not able to use an controls from WinJS.

I hope my problem is straightforward and someone can tell me what reference to include, otherwise, I could include code but I am not sure it could really help to understand...

Thanks for any advice, Claude


Solution

  • If you look in the Navigation template project, you'll see navigator.js in the js folder. This is the implementation of the PageControlNavigator class, so you just need to pull that one file into your Cordova project. This is separate from WinJS.

    For WinJS itself, the best thing to do it get the latest (3.0) from http://try.buildwinjs.com/#get. You can either get the full package, or you can do a custom build with only the features you want (there's a link at the bottom of the page for this).

    One thing that's important to understand is that on Windows Phone 8, the HTML/JS of a Cordova app will be running in a webview inside a Silverlight app host. This is a big reason why you want to use WinJS 3, because the 2.1 code from a Windows Phone 8.1 project will have some thing that don't work quite right. The navigator.js code, however, doesn't depend on any of those and should be fine to use.