Rusty Divine

Live, Love, Learn, Teach

#HDC12–Building Win8 Apps with JavaScript

I’d like to thank HDC12, Jeff Brand and Matt Milner for a great hands-on lab today on building Win8 apps with JavaScript.  We worked through a demo project that queried Twitter for tweets based on a search string, then presented the results in a nice grid.  Each cell in the grid had the author’s picture and the tweet.

Jeff made the demo project available via Git:

Resources on Win8:

Here are a few things you need to know about developing a win8 RT app on the JS stack (some of these would apply to a xaml app on WinRT, too):

  1. You can't reference js from a CDN or internet; has to be local.  The app has to be able to run disconnected, and has to be run in one security context
  2. In un-snapped view, the app layout needs to scroll horizontally, not vertically
  3. The app is suspended when it is not visible.  After a while, if resources get low, Win8 will terminate your app and not tell you! So, on receiving the suspend event, assume you are/will be terminated because there is no event for terminated and go ahead and save state or whatever you need to do.
  4. You have to have win8 & vs12 to develop the apps – they use WinJs which relies on WinRT
  5. The app has to support snap view – when the app gets snapped to the side.  At that point, it needs to either scroll vertically or handle the change gracefully.  For instance, a game might just put up a “paused” screen in that case.
  6. The most common architecture will probably be a single-page-app.  You can use js namespaces to avoid script collissions.
  7. Make sure to check the project’s manifest in the package settings to set the capabilities and available declarations so that the app can access more than just the Internet.
  8. Blend visual designer is definitely worth checking out.  It renders the app in an engine that includes a javascript sandbox.
  9. You can hook into the Search/Share/Settings charms to set up how your app will interact with these
  10. You can add custom buttons to the app bar – be sure to check the metro design guidelines for where to put global vs context-sensitive tools.
  11. The app store reviews all apps.  If you are selling yours, there is a tiered pricing structure starting at $1.99.  MS takes 30% of sales up to $25k, and 20% after.  If you don’t sell the app, it can be added to the store for free and MS provides advertising tools (or you can use others), and you can still use a payment gateway in the app without having to pay MS.  So, the only time you pay MS is if the app is for sale.  There are very easy ways to make it a trial software for 7/14/30 days (e.g.) and MS will handle users trying to trick the trial by uninstall/reinstall or other means.
  12. When an app is off-screen, it gets 0 CPU.  A device can have up to 7 apps that are running background processes (think email, IM), and the user will choose which of their apps win if there are >7, so don’t assume your background polling process will be running if your app is suspended.  You can also do live tiles for the start screen that use push notifications or toast notifications, and this is a free service that MS provides.  For some rare cases, like a skype app, there are ways to keep a connection open even if the device is locked.
  13. You can have multiple tiles for one app – think a separate tile for each stock you are tracking in the financial app.
blog comments powered by Disqus