Getting Started with Windows 8

Getting Started with Windows 8

This guide describes how to set up your development environment for Cordova and run a sample application. Note that Cordova used to be called PhoneGap, so some of the sites still use the old PhoneGap name.

During development of Windows 8 and Windows RT, Microsoft deprecated the name "Metro-style apps". On MSDN, this type of app is now called a "Windows Store" app. That's the name that we'll use in this guide. Also in this guide whenever we refer to Windows 8, you should take that to mean both Windows 8 and Windows RT.

1. Requirements

Follow the instructions here to submit your apps Windows Store.

2. Install SDK + Cordova

3. Setup New Project

You can already build Windows 8 apps using the "HTML/JavaScript track" available in Windows Store apps. The purpose of Cordova in Windows Store apps is to expose the same APIs used on all the other Cordova platforms.

Adding the reference...

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

    <!-- Cordova -->
    <script src="/js/cordova.js"></script>

    <!-- CordovaWin8Foo references -->
    <link href="/css/default.css" rel="stylesheet" />
    <script src="/js/default.js"></script>

Adding a 'deviceready' handler...

<body>
    <p>Content goes here</p>

    <script type="text/javascript">

        console.log("Subscribing...");
        document.addEventListener("deviceready", function () {

            navigator.notification.alert("The device is ready!");

        });

    </script>

</body>

5. Test the Project

Done!

That's it! You're now ready to build Windows Store apps with Cordova.