iOS and JavaScript Bridge

What if you need to write a completely dynamic app, and you need to have the ability of updating the App’s contents remotely, without the need of pushing a new build to the AppStore?.

What if you need to write javascript code, which needs to interact with your iOS code?.
Yeah. I had that problem. Long short story, i’m testing a nice framework called clutch.

Clutch has a nice JavaScript and iOS SDK, which smoothens the interaction between those two technologies. When you ship the app, you bundle a version of the webApp in it.

If the app has no internet access, it will rely on that bundled web. And as soon as you launch it, it gets sync’ed with the backend. (You can actually push ‘new version’ to the Clutch backend).

So far… i’m loving it. Go, try it… and let me know what you think!.

If you just need to build a dumb iOS and JS bridge, i suggest you also check out this github project, and this one.

AES Encrypted Chat!

Well, this time i’m not gonna share an HTML trick, library, or whatsoever. A friend of mine sent me a link… and i said… WOW… this is written in javascript alone?.

It’s a web-based, encrypted chat. Pretty amazing… there is no java applet anywhere to be seen. So… it’s kind of a disposable, encrypted chat. If you wanna… have a secure communications channel, for whatever reason, you can give it a shot.!

The UI is retro… it feels like playing with the chat they’ve used in ‘The Net’ film. Check it out..

Targetting iPhone 3gs and superior

I recently had a problem with one of the apps i’m working on. (Yeah, yet another problem!). The first release supported ARMv6 (which is handy when targetting older devices, as well, such as 1st and 2nd iPod generations, and the old iPhone 3g).

As it turns out, you cannot change the requirements of an app after pushing an update. I mean, you cannot simply remove ‘ARMv6’ support. Apple’s policy is that … you should continue supporting all of the target platforms you’ve enabled in the very first release.

So far so good. But what happens if you need to link a library which is built for ARMv7, without ARMv6 support?. Two options… one… weak linking. The second, would be to simply deprecate ARMv6. But apple… doesn’t want this.

Hey… wait… there is a catch to it!!. If you update the ‘target iOS platform’ to iOS 4.3 (or higher)… you can safely drop ARMv6 architecture.

Why?. iOS 4.3 cannot be installed on older devices, such as the iPhone 3g. It doesn’t support ARMv6 architecture.

So… long short story… the only way to safely drop armv6 support is by setting an upper target platform (4.3+).

Who’s using anything older than that???. Go on… deprecate those old devices!. They have already fulfilled their cycle…

 

GPS in Safari Mobile

So… what if you wanna get the GPS position, but within a WebApp’s context?. There are several tools, such as PhoneGap, that encapsulate GPS access. But it turns out that there is an extremely easy way to accomplish this task.

Check out this JavaScript snippet… easy, right?

navigator.geolocation.getCurrentPosition(foundLocation, noLocation);

function foundLocation(position)
{
  var lat = position.coords.latitude;
  var long = position.coords.longitude;
  alert('Found location: ' + lat + ', ' + long);
}

function noLocation()
{
  alert('Could not find location');
}