Posts Tagged ‘iphone’
… 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.
With the iPhone 3.0 firmware released today, I thought I’d show you how to access one of the features I’ve been most looking forward to – support for the geolocation API in Safari means I can now create location aware websites.
This will be just a quick demo to retrieve and display the current longitue and latitude of your phone, along with a googlemap so we can see if the results are right. The more interesting applications will come….
To do this we’ll use javascript and the newly added Navigator.Geolocation interface to call the getCurrentPosition() function to retrieve the current longitude and latitude of the phone, which we’ll display and pass to the googlemaps API.
The code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>iPhone 3.0 geolocation demo</title> <meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/> <script> function handler(location) { var message = document.getElementById("message"); message.innerHTML ="<img src='http://maps.google.com/staticmap?center=" + location.coords.latitude + "," + location.coords.longitude + "&size=300x200&maptype=hybrid&zoom=16&key=YOURGOOGLEAPIKEY' />"; message.innerHTML+="<p>Longitude: " + location.coords.longitude + "</p>"; message.innerHTML+="<p>Latitude: " + location.coords.latitude + "</p>"; message.innerHTML+="<p>Accuracy: " + location.coords.accuracy + "</p>"; } navigator.geolocation.getCurrentPosition(handler); </script> </head> <body> <div id="message">Location unknown</div> </body> </html> |
The results:
- iPhone OS 2.2.1
- iPhone 3.0
- iPhone 3.0 – I am here!
Try it for yourself by pointing your Safari browser at http://bemoko.com/blog/iphonegeo.
Update 27/7/2009: I noticed the zoom level on the google static map API wasn’t being set so the map was zoomed all the way out. I’ve added a default zoom for the demo code above. Not sure if thats a new requirement from Google’s side?
Let’s start with the depression and then I’ll lift you. There are a lot of big name device manufactures that are really struggling at creating that goal of usable mobile internet devices. So apple have paved the way and although they weren’t at the MWC this year – the iPhone they released over a year a go would still have been the cream of today. So what is the competition missing? LG, Samsung and Toshiba are all creating smartphones that miss on so many fronts – clumsy UI, unresponsive touchscreens and slow interactions. Docomo show some promise of innovation with the push into projector phones and I’ll keep an cautious eye on Huawei now that they’re press released their Android strategy and put a shiny phone in a glass box.
The Nokia N97 is making small step forwards, but it doesn’t feel a leap from the excellent N82. I like the home page widgets and the personalisation that comes from this, but the UI is a little tired and was slightly unresponsive. Not a bad phone, but didn’t impressed me like I wanted to be impressed.
When we finally tracked down the HTC Magic we got a glimmer of hope. The device was responsive and showed promise, but it still was lacking that end-to-end-I-want-one feeling. The UI is slightly cluttered and, although it looks more robust than the G1, it still needs someone to take Android and create a polished experience (a goal I don’t think is far off and I strongly believe will happen). A disappointment I’d had on previous windows mobile device was reaffirmed at HTC where I could try the HTC Magic (Android) against the HTC Diamond (Windows Mobile). The HTC Diamond felt it was stuck in the wrong gear. Other people have commented on a similar windows experience – Gizmodo, Edible Apple, PPCKitchen. Is it the hardware / touch screen or is there something inherently up with Windows mobile usability?
I was pleasantly surprised to see Garmin asus make a worthy contender with the G60. Garmin have Android rumours all over them – something that the Garmin representative did nothing to hide – but for the time being the G60 is linux based. Garmin I know well from the satnav section of my Halfords store and Asus I know well from defining and conquering the low priced, well built small laptop market. What a great combination of two trusted brands. People are already budgeting for Garmin satnav devices so the cross over into a tight mobile internet phone seems perfect. The G60 UI is clean simple fast and does the job. It doesn’t show off and isn’t trying to be an all functional smartphone, but it has it’s worthy place and things can only look up for Garmin as they take this strategy forward. Lot’s of choices for them on the direction – not least their distribution channels and how they engage with the operators.
So … leaving the best for last. We were blown away by the Palm Pre – something that Tim has already blogged about. So now wanting to repeat his message, I’ll quickly summarise my thoughts. It’s such a rounded device – both physically (like a polished pebble) and user experience wise. For me user experience is everything – if something annoys or bugs me in a device then it can ruin the whole experience, but here is a device that I couldn’t fault. Albeit, through the rose tinted glasses of desire, I did try to find faults – but they were difficult to find. A few days in my pocket may unearth some. The battery life might be an issue as could the price tag – rumoured at ~$500 (keeping it firmly in the high price end of the market). Those aside – we’ve got a very user-centric device here. Palm have thought about the user and what they want and that includes multi-tasking/multi-cards, clever gestured, subtle on screen feedbacks (where your finger has been), consolidated search interface. The synergy concept to aggregate contacts and calendars from multiple source is great from a consumer view, pulling together social contacts, but also from an enterprise side where it could be pulling in contact from your CRM. This device really is true cross over between consumer and enterprise, seemingly without compromise to either (we’re all people aren’t we so it should be possible). I can see people who like the iPhone and people who like the Blackberry take more than a double look at this Palm pre device and consider that it’s time for a change.
… and did I say the Palm Pre packaging is neat. All recyclable, no bits of plastic and unnecessary plastic bags, whether they did this for marketing or altruistic reasons – it doesn’t matter. It shows they care.
Take care – and here’s to an exciting future for the (mobile) internet.
In the end, and after my much deliberation, I went for the Nokia E61i as my new phone. I always liked the Nokia E61 which was my main phone for most of last year and once you’ve got over the form factor well the E61i is a natural upgrade path. I did ponder over the iPhone, but �269 is just a little too much as an inital payment, when I can get better hardware for “free”. Oh but the UI is so sweet. A colleague got me interested in the Samsung F700, but thankfully I didn’t since the same colleague took the phone back after a few days, as it was pretty deficient in several ways (such as poor PC synchronisation, bad use of the big screen and poor support from Samsung). Maybe Samsung’s software issues will go away when they start building on top of the Android platform. This is not too far in distance since Android is leaving the virtual world and becoming a reality as EU Edge demonstrate with a deployment of Android on a Sharp Zaurus SL-C760. The $10million purse for the best mobile apps should also help things along. I’ll find out more at Google’s Android day in London this Thursday.
So why the the Nokia E61i then?
The Wifi support is great. I would love to see better wifi hoping functionality, such as utilising the access point groups to define my preferred access points in order and better support across all the apps. I seem to spend a bit of time in each app switching between access points, but at least connection is pretty solid once set up. Wifi usage does help reduce my Vodafone data usage which is capped at a less than attractive 120Mb per month.
With the E61i, the synchronisation of email, contacts and calendaring is pretty seamless. I’ve got it hooked up to our Zimbra server using the Nokia’s Mail for Exchange client (which you can clearly use for Exchange if you have that). I went for syncing my contacts via my mac with iSync because (i) I was playing around with iSync at the time and (ii) it lets me sync my contacts without an internet connection (e.g. when I’m travelling abroad). You’ll need to download the iSync plugin for the E61i since it isn’t provided by default. With the E61i I really can have my email, contacts and calendaring kept in sync between my phone, mac and zimbra effortlessly.
The E61i has also thrown in a camera which is a nice addition over the E61. Don’t expect too much from the camera, but it’s enough for my purposes which are general taking photos of whiteboards and quick photos on business trips to send back to my wife.
The UI is intuitive and quick – the ability to configure the shortcut buttons allows me to get to what I want to quickly. The screen and keyboard are fantastic – I can easily read my inbox and write messages whilst in queues and on the move. Of course the mobile browsing can pretty much read anything out there and do a reasonable job on it, whether I’m using the default browser or opera mini.
So all in all a pretty handy device whilst I’m out and about (or even at home but don’t want to flip out my computer to read my mails). And with a bluetooth headset I don’t have to put the brick that it is to my ear.



