Announcing PhoneGap for Windows Phone Mango | September 8th, 2011
Over the last month and a bit, Nitobi has been working closely with Microsoft to bring PhoneGap to WP7 devices. I am happy to say that it’s now here, and ready for beta exposure.
The Genesis of PhoneGap for Windows Phone 7
Our starting point was the excellent work of Matt Lacey, who created the initial project and did the initial exploration of device functionality. The upcoming Windows Phone Mango update to devices brings a rich set of HTML5 features and IE9 to the device.
Thanks to Microsoft sponsorship, Sergei Grebnov has been making contributions to the code and has implemented the MediaCapture and Camera APIs. This is Sergei’s first foray into PhoneGap, but he has proven to be a valuable asset to the project and was up to speed quickly.
Nitobi has dedicated two developers to the project, myself and Herm Wong. We’ve been busy dusting off our Sliverlight+C# skills and implementing the other APIs. ( the infamous Shazron has also jumped in just this week )
Here’s the outcome!
Some code here : https://github.com/phonegap/phonegap-wp7
Some more info here: http://bit.ly/PhoneGapMangoIntro
What You’ll Need to Get Started
So you want to get on it, enough talk? You will need Visual Studio 2010 with the “WP7 SDK” : http://create.msdn.com/en-us/home/getting_started installed (the free express version works fine )
Detailed instructions will be posted shortly as a getting started guide on PhoneGap.com, in the meantime :
- fork/git or download/unzip the repo to your harddrive
- copy the file GapAppStarter.zip to the folder : \My Documents\Visual Studio 2010\Templates\ProjectTemplates\
- Launch Visual Studio 2010 and select to create a new project ( PhoneGapAppStarter should be listed as an option, give it a name )
- Right-Click on the solution and select Add->Existing Project, and add the project : framework\WP7GapClassLib.csproj from the downloaded repo
- Right-Click your main project and “Add Reference” to the WP7GapClassLib project
- build and run!
Where Are We ? What APIs Are Done?
Here’s an overview of where we’re at:
- Accelerometer
- Camera
- Compass (unit testing is waiting on us having a device that supports compass)
- Contacts
- Events (partial, still underway)
- GeoLocation
- MediaCapture
- Connection
- Notification
These have all been implemented per the spec, and function as expected with some quirks being added to the documentation as you read this.
The ‘deviceready’ event is fired on startup, and like other device platforms, is the signal that you can begin making PhoneGap API calls.
The GeoLocation API did not require any work, as IE9 implements the spec as defined by W3C.
Still to come :
- File
- Storage
How Does it Work? A peek under the hood.
PhoneGap-WP7 includes a library project which contains the core functionality, and you reference this project from your own project. Your own project will include the www folder which is where your Gap html/js/css will live. All files in the www folder must be added to the project in Visual Studio and marked as content so they will be packaged with your app when it runs on the phone. We will be releasing a Visual Studio template to allow you to simple select NewProject->PhoneGap-WP7 project and auto-magically be on your way.
Packaging of applications is quite different on WP7. All resources (your PhoneGap js/html/css code in the www folder) are packaged into the XAP as resources but cannot be accessed directly at runtime, so an extra unpackaging step is required.
When the app is first run, all resources listed in the manifest are copied from the binary XAP to IsolatedStorage. IsolatedStorage is a per application File location, similar to a per app Documents folder in iOS. IsolatedStorage is managed per app, so separate applications cannot interact with the same document store. We are working to make this as transparent as possible, so your workflow does not have to change. Build scripts and tooling will eventually take care of the dirty work, but for now you will be building directly from Visual Studio.
After unpackaging the contents of the www folder, your www/index.html file is loaded into an embedded headless browser control. This is essentially the same paradigm as other platforms, except here it is an IE9 browser and not a webkit variant. IE9 is a much more standards-compliant browser than previous IEs, and implements commonly used html5 features like DOMContentLoaded events, addEventListener interfaces, and CSS3. Be sure to use to get the html5 implementation otherwise the browser may fallback to a compatibility mode, and your code will likely choke and die. You should also use in your html .
Gotchas + Known Issues
IE9 does not expose touch events, or even mouse events to JavaScript. The only UI event that is available to your code is the click event. This means that many interfaces that are based on scrolling libraries and a WebKit DOM will not function as expected. The browser control DOES appear to support the CSS value of overflow:scroll, however there is no momentum and the scrolling feels sticky. I have done some quick exploration into exposing mouse events to JavaScript via the container and they do look promising. I will be moving on to this after I completed the Events API so your code can override the back-button and search-button.
IE9 supports localStorage, and sessionStorage, however they are not available to pages that are loaded without a domain. We will be investigating implementing this API ourselves, and managing the storage in IsolatedStorage.
Reporting issues, tracking progress and keeping up to date.
The project code is maintained on github at https://github.com/phonegap/phonegap-wp7, so you can follow it there. Any issues you come across can be filed in the Issue Tracker on github.
As with the other devices, general question can be directed to the PhoneGap mailing list, where the community is ready and waiting to help. For questions specific to Windows Phone 7, please include ‘WP7′ in the subject.
Will PhoneGap for WP7 support plugins?
This was a key focus, as keeping the architecture plug-able is a primary concern, and in my view, where the real power lies.
PhoneGap-WP7 maintains the plugability of other platforms via a command pattern, to allow developers to add functionality with minimal fuss, simply define your C# class in the WP7GapClassLib.PhoneGap.Commands namespace and derive your class from BaseCommand.
PhoneGap exec works in exactly the same way as other platforms :
PhoneGap.exec(callbackSuccessFunction,callbackErrorFunction, PLUGINNAME, PLUGINMETHODNAME, paramObj);
What is Left to Do? How can You Contribute?
Sergei has begun working on the File API, so you can expect full file access to create, modify, delete files as well as upload/download to/from a server.
I am busily trying to wrap up some of the life-cycle events (Events API) so your application can be notified when the app is pushed to the background. I will be looking into exposing mouse events to JavaScript shortly after that.
If you have expertise in any of the Native portions, or JavaScript, you are welcome to fork the repo on github.
Keep in mind: PhoneGap can only accept pull requests from contributors who have signed the CLA so we can make sure that PhoneGap remains open source and free. PhoneGap is dual licensed as defined here : http://www.phonegap.com/about/license
Even if you don’t contribute code back, I/we would love to hear about your experience building with PhoneGap for WP7, good, bad or indifferent. Please direct your kudos, or comments to the Facebook page at http://www.facebook.com/PhoneGap. You are also welcome to contribute to the documentation, and wiki pages, got a great getting started tutorial? Let us know! Want to tell the world about your WP7 PhoneGap app? Let us know!
We will be posting new information to the blog as updates are made, as well as on the mailing list, and PhoneGap.com.
Forever Endeavor
-jm
[Update]
here’s the twitter credits :
Matt Lacey : @mrlacey
Herm Wong : @hermwong
Shazron Abdullah : @shazron
Me : @purplecabbage
PhoneGap : @phonegap
Nitobi : @nitobi
September 8th, 2011 at 8:47 am
[...] bring PhoneGap to WP7 devices. I am happy to say that it’s now here, and ready for beta exposure. Link - Back to Viral Tweets Related Posts:The Gas Has Been Passed From iPhone To Windows Phone 7: [...]
September 8th, 2011 at 9:57 am
Will it be available on PhoneGap Build aswell?
September 8th, 2011 at 11:05 am
[...] Read more at Nitobi here. [...]
September 8th, 2011 at 12:07 pm
Yeah, definitely! It would be silly not to.
September 8th, 2011 at 4:46 pm
[...] Nitobi, via: Windows Phone Developer [...]
September 9th, 2011 at 3:52 am
LIKE! That’s really awesome, guys!
September 9th, 2011 at 3:56 am
[...] encourage you to read Nitobi’s blog post to get more details on how the whole process [...]
September 9th, 2011 at 6:51 am
[...] Nitobi, the company behind the cross-platform mobile software framework PhoneGap, have announced upcoming support for Windows Phone 7. [...]
September 9th, 2011 at 9:58 am
[...] Support bereitgestellt. Nähere Details zum Einsatz von PhoneGap für Windows Phone 7 finden sich im Nitobi-Blog. Veröffentlicht von admin am 19:58 Kennzeichnung: Phone 7.5, PhoneGap, [...]
September 9th, 2011 at 11:11 am
[...] a Sept. 8 blog post, Jesse Macfeyden, senior software engineer at Nitobi, the maker of PhoneGap, said a new beta of PhoneGap for Windows [...]
September 9th, 2011 at 7:26 pm
[...] comes to Windows Phone By tim, on September 10th, 2011 Follow tim on Twitter Nitobi has announced PhoneGap for Windows Phone 7, nicely timed just before the Microsoft BUILD conference next [...]
September 10th, 2011 at 11:20 am
[...] a Sept. 8 blog post, Jesse Macfeyden, senior software engineer at Nitobi, the maker of PhoneGap, announced a new beta of PhoneGap for [...]
September 10th, 2011 at 6:59 pm
[...] more details and information please read Nitobi’s blog post to get more details on how the whole process works. With the availability of Windows Phone [...]
September 11th, 2011 at 3:47 am
I gave it a try, but building failed with:
The ‘ProductID’ attribute is invalid - The value ‘$guid1$’ is invalid according to its datatype ‘http://schemas.microsoft.com/windowsphone/2009/deployment:ST_Guid‘ - The Pattern constraint failed. GapAppProj
September 11th, 2011 at 9:13 am
[...] can get more details here Getting Started with PhoneGap for WP7 Mango and also Announcing PhoneGap for Windows Phone Mango Download framework and example [...]
September 11th, 2011 at 10:59 pm
[...] a great Vancouver-based company with a strong history in building mobile development platforms, has announced the release a beta of its popular PhoneGap framework supporting Mango. This is a really big deal, not only for Microsoft, but for you as a mobile developer. [...]
September 12th, 2011 at 10:01 am
[...] to a blog post by Nitobi's Jesse Macfadyen, these are the APIs that PhoneGap has set up for [...]
September 12th, 2011 at 10:01 am
[...] to a blog post by Nitobi's Jesse Macfadyen, these are the APIs that PhoneGap has set up for [...]
September 12th, 2011 at 10:14 am
[...] to a blog post by Nitobi's Jesse Macfadyen, these are the APIs that PhoneGap has set up for [...]
September 12th, 2011 at 6:50 pm
Tomsh, just run it again, that error is a known bug
September 19th, 2011 at 5:06 am
I am very very happy now, when will announcing in full version of Windows Phone7 mango. we are waiting for us
September 25th, 2011 at 12:04 pm
Will there websql be supported..? For us, this is a biggie amd MS have stated that they won’t support it.
September 26th, 2011 at 1:57 pm
Eventually yes, but certainly not in the short term, unless someone from the community steps up and implements it.
September 27th, 2011 at 11:57 pm
[...] the darling of the cross platform community (and I am a fan!) already work this way with phonegap. Phonegap recently announced support for the mango platform in addition to iPhone, Android and others it already supports. Thus, the mobile cross-platform [...]
September 29th, 2011 at 7:37 am
[...] an initial implementation of the PhoneGap APIs. More recently Nitobi (who run PhoneGap), announced an official beta release, which they have worked on in conjunction with [...]
September 29th, 2011 at 10:27 pm
Great work Jesse and gang. You might be interested in this article I wrote on PhoneGap development:
http://www.scottlogic.co.uk/blog/colin/2011/09/developing-windows-phone-7-html5-apps-with-phonegap/
Regards, Colin E.
September 30th, 2011 at 12:25 am
And nice work from you as well. Right now we need people using it, so we can focus on the right things.
Thanks for sharing your experience.
September 30th, 2011 at 5:56 am
[...] an initial implementation of the PhoneGap APIs. More recently Nitobi (who run PhoneGap), announced an official beta release, which they have worked on in conjunction with [...]
October 6th, 2011 at 1:31 pm
[...] Phone 7 (ami az el?z? ábrán még szerepelt), aminek egyszer? oka van. Íme egy bejelentés: Announcing PhoneGap for Windows Phone Mango [Jesse MacFadyen, Senior SE, Nitobi, Sept 8, 2011], amib?l a következ?ket érdemes idézni: Over [...]