Glenn's Junk Chest

An assortment of Glenn's writings, photography, gaming resources, flash movies, and other creative output.


Monday, July 09, 2007

iPhone Hack - The Lightest of Tethers

One of the limitations on the iPhone is that it doesn't support "tethered mode", which is where you hook it up to your laptop (either by bluetooth or cable) and use it as an external modem to get your laptop online.

The reason for this limitation is probably threefold. 1) AT&Ts EDGE Network is slow, and possibly overburdened for this purpose. They may have been reticent to have a bunch of bandwidth-hungry laptop users with shiny new iPhones flooding onto it. 2) AT&T charges extra for this service. 3) The phone plays big to people that are often in Wi-Fi enabled areas. Such people don't need a tether, and may chose another phone anyway, thus making heavy R&D investment in this space a dubious investment.

The most galling limitation of this, for me, proved to be in composing email. I'd want to send an email from a non-wifi area, and could either compose it on my laptop and wait to send it later, or compose it on my iPhone, which doesn't allow for easy composition of long email messages. (little keyboard, small view space, no cut and paste, etc.)

So, the question in my mind became, how do I write an email on my laptop, then sync it to the iPhone and send it? The mail sync on the phone syncs only account info, not content. The notes application doesn't sync. You could write the message into an address book entry (maybe) or a calendar entry (maybe), but without cut and paste, there's no way to get it into the mail program. In fact, the only content that syncs from your computer to the iPhone that you can send via email is photos. This does work, if you put your email body into a 320x480 image file, sync it to the iPhone as a photo and then email it, people can get your message as an image. It's a terrible kludge, but with photos being the only synced and mailable content, there was no other way.

Or was there?

The iPhone allows for one more data type to be synced. The Safari bookmark. (It allows IE bookmark syncing on Windows, but I haven't tried that.) For sending email, this offers two possibilities.

The first is that you could create or use a web service somewhere that allowed messages to be encoded in the URL used to access the service. Such as:

http://www.fakeemailservice.com/email.php?body=This+is+my+message!

Make this into a bookmark, sync it to your iPhone, and then use the service to send the email. This solution has a lot going for it, but wasn't quite what I was looking for. I wanted to use the mail program (already configured on my iPhone) with the accounts found there.


The second (drumroll please) is that you could encode the message as a "mailto" link, like so:

mailto:glenn@theMediaNinja.com?subject=Test&body=This+is+my+message!

When you make such a link into a bookmark in Safari, sync it to your iPhone, and then select it from the iPhone's bookmark menu, it pops up the mail interface, with addressee, subject, and body intact. You can then send it right from the iPhone. I don't know how long such a bookmark can be, but it's at least several thousand characters.

In order to take advantage of this capability, you'll need to URL-encode the body of your message. (this is because characters like & and % are reserved, and because you want to replace spaces and carriage returns). The iPhone also has a slightly non-standard way of converting mailto links, in that it doesn't use %0D or %0A for carriage returns, but instead likes "<br>". (This suggests that you might be able to use this technique to build more complete HTML to send from the mail program, but I haven't tried that yet.)

In order to make this more palatable, I have created a quick-n-dirty flash movie that does the proper URL encoding, you can try it or download it from:

http://www.themedianinja.com/linked/textprocess_iphone.swf
(option-click or right-click the link to download it.)

Remember to download it if you actually want to use it at some point. Hope this helps someone out!

Suggested improvements welcome.

Labels: , , , ,