In this article I will talk about how to get started with Cordova (formerly PhoneGap) in Windows Phone.
Step 1: Download PhoneGap from here. At the time of writing this article lates version of PhoneGap available was 2.0.0.
Step 2: Unzip the downloaded file.
Step 3: Search for CordovaStarter-2.0.0.zip in the unzipped folder downloaded in the above step. In earlier version it was PhoneGapStarter.zip. In 2.0.0 the location of CordovaStarter-2.0.0.zip is as shown below.
Step 4: Place the CordovaStarter-2.0.0.zip in \My Documents\Visual Studio 2010\Templates \ProjectTemplates
Step 5: Now open VS2010 and Create New Project, Select Visual C# from Installed Templates option and you will get option of CordovaStarter-2.0.0. Now click OK.
Step 6: The project structure looks like below in Cordova 2.0.0.
Step 7: Now we are all set to use PhoneGap or Cordova. Open index.html. index.html gets loaded when you run the applicaiton.
It is important to make sure device is ready before you try to access device properties. The API might not work correctly if the device is not ready.
PhoneGap or Cordova provides onDeviceReady method which gets invoked when device is ready.
Place below code in the index.html page.
Step 8: Now run. the application and once device is ready, alert will be displayed like below.
This ends the article of getting started with PhoneGap or Cordova in Windows Phone.