Posts Tagged ‘HTML5’

… or in other words we can readily synchronise local browser storage with back-send server persistent storage. This is one of the fundamentals of compelling off line web applications.

So a little background. You may know that you can store data in your local browser database with javascript like …

1
2
3
4
5
6
7
8
9
10
11
12
13
function store() {
  if (window.localStorage) {
    var count=window.localStorage.getItem("count");
    if (!count) {
      count=0;
    }
    count++
    window.localStorage.setItem("count",count);
  }
}
window.onload = function() {
  store();
}

and you can even see it in action here, if you got a decent browser such as the latest iPhone 3, Firefox 3.5, Safari 4.

But this ain’t much good if you can’t get this data back to the server to do something useful with it, e.g. share with friends, share with your other devices, keep a backup, send a message … I could go on.

So what we really need is a way to easily listen out to storage events and deal with it in one place. Yep, we could create our own Javascript framework to do this and handle getters and setters, but that sounds nasty to me.

Instead we can know use the onstorage attribute on the HTML body tag to hook into a function that will handle all of these call backs based on local stored data.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function store() {
  if (window.localStorage) {
    var count=window.localStorage.getItem("count");
    if (!count) {
      count=0;
    }
    count++
    window.localStorage.setItem("count",count);
  }
}
function handleOnStorage() {
  myFunctionToSendDataToServer(event.key,
    event.newValue, event.oldValue);
}
window.onload = function() {
  document.body.setAttribute("onstorage", "handleOnStorage();");
  store();
}

Take a look at it in action here in the bemoko mobile test suite. It works on iPhone 3 and Safari 4. You can even see the complete code here.

So, “The market for mobile applications, or apps, will become ‘as big as the internet’, peaking at 10 million apps in 2020″ says GetJar – see BBC – Apps ‘to be as big as internet’ and GetJar forecasts 100,000 mobile apps by end of 2009. With Juniper Research predicting 20 billion app downloads by 2014 this a great outlook for mobile apps. But we shouldn’t be thinking of apps as an alternative to the internet. We really need to be thinking of them as one.

The buzz at the moment is clearly on app stores with the iPhone app store clearly leading the pack. See BBC’s click online summary from last week – Mobile phone applications grow up – for a great picture of the status quo.

We naturally turn to the ongoing debate of apps vs browser – Apps or browser? GetJar vs. Google on the future of mobile services. We needn’t think about either approach being right or wrong, or whether one approach will beat the other, especially when you consider that the user experience and commercials demands can vary wildly in different sectors or demographics. Let’s instead think about how the boundaries between the downloadable app and the web app can become blurred – creating a seemless experience for the end user.

Personally I’m getting pretty excited about the emergence of HTML5 web app stores as the HTML5 browser support arrives. We’re already seeing a taster of this HTML5 support, with the iPhone geolocation support in iPhone 3.0. Many apps currently in the app store realm lend themselves well to a personalised microsite with offline capabilities (such that HTML5 will enable) – take any of the information driven ones as examples, such as Amazon Mobile or Things. Developing in HTML5 brings with it the benefits of delivering to a wider set of devices and reusing existing web dev skills to create the apps. With these benefits in mind, the Open Gardens blog covers brilliantly the challenges that have to be tackled to create an HTML5 viable ecosystem – most importantly, what is the incentive for all the participating players.

We see the likes of (1) Nokia with their WRT widgets having foundations in HTML, CSS and Javascript and (2) Palm using HTML5 for native application – both providing potential alignment with the HTML5 web app store approach.

Now it’s really Google who is going all out for this HTML5 web app approach. With a slew of hot Android devices coming onto the market we can see Google slowly taking a slice of the smartphone. With the Android, Palm WebOs and Safari (iPhone) browsers all based on Webkit and with Webkit promising great HTML5 support things do look bright for HTML web apps.

BTW – to make my bias known – I co-founded bemoko which specialising in the delivery of the web to mobile. We have created a platform that allows existing (normal) web developers to deliver excellent mobile web UX – along with this wave of HTML5 (and widget) dev that is coming.

Posted in: mobile No Comments