Way back, one of our readers begged for an iPhone LoJack solution. He wanted his iPhone to "call home" regularly in case of loss or, let's be more realistic, theft. Over the past week, I finally had a chance to give this request some time, and I put together findme. It's a command-line program that returns the location of the cell phone tower nearest to your iPhone. When run, it tells you the tower id, plus its latitude and longitude courtesy of Google Maps.
Still, how to get the location report to a place you can get it... but nobody else can... and without receiving a zillion SMSes? For this part of the puzzle, enter Twitter. Twitter dev Britt Selvitelle helped walk me through the setup for a private account that allows your iPhone to phone home but keeps the location data relatively secure.
To do this, create a new Twitter account just for your iPhone (it will need its own unique email address, separate from your main account, so have one handy). Open the Settings panel, and look for the "Protect My Updates" checkbox. It's towards the bottom of the page, just above the Save button. Check this and click Save. With protected updates, only the Twitter users you approve will see the updates for this iPhone-only account (just you? you + spouse? spouse, kids, and "special friends?" Up to you).
Update: I've put an updated version of findme (findme-better) into the TUAW folder on my site. Please let me know if this works better for location for you. To use, just copy to your iPhone (you may have to use Firefox if you get errors after downloading with Safari), rename to "findme" and replace the original findme.
After creating your phone's Twitter account, you're ready to set up your iPhone to tweet in on a regular basis. Here's how.
1. Install findme Add findme to your local binaries folder. Under 1.1.3, I've been using /var/root/bin for my utilities. If you use another location, substitute that path for mine. Make sure to chmod 755 findme so that it can be executed.
2. Make sure you have curl It's a standard part of the BSD distribution, if memory serves. You'll need it to contact Twitter. Your iPhone will only be able to call in via curl and Twitter if it has Internet access, through EDGE or WiFi.
3. Create a tweet shell script Copy the following text into a new text file, and add it to your binaries folder.
#! /bin/sh
curl --basic --user username:password \
--data status="`/var/root/bin/findme`" \
http://twitter.com/statuses/update.xml
Use the proper path to findme and substitute your actual username and password. Make the file executable, i.e.
chmod 755 tweet
4. Create a launch daemon In /System/Library/LaunchDaemons, you'll find a simple daemon that runs once a day, called com.apple.daily.plist. Copy this to com.sadun.tweet.plist, and edit it as follows:
- Update the Label to com.sadun.tweet.
- Kill the two lines that relate to "nice". You don't want your lojack to be usurped by other processes.
- Change the program arguments to /var/root/bin/tweet.
- Change the start interval from 86400, according to your needs. 86400 is once a day (60 seconds * 60 minute * 24 hours). Right now, I have mine running every ten minutes (600) because I needed to check that the LaunchDaemon was functioning properly.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sadun.tweet</string>
<key>ProgramArguments</key>
<array>
<string>/var/root/bin/tweet</string>
</array>
<key>StartInterval</key>
<integer>600</integer>
</dict>
</plist>
5. Reboot. This allows our iPhone to restart, loading your new launch daemon.
The findme software was written around material orginated by the iPhone dev team and by Hisper of the Google Maps online developer forum, and was helped by Saurik -- because the iPhone's built in host name resolution is horrible. Thanks also to aCujo for his help. The Twitter curl calls are courtesy of Britt's brilliant assistance. You can drop him a note to say thank you. Thanks also go to Mike Rose, whose idea it was to use Twitter instead of SMS.
Tip: If you find that your tweets are full of "Location Not Found" messages, edit the tweet shell script and duplicate the curl call. This runs the call twice. Usually the "Location Not Found" message goes away the second time.
Another Tip: If you're traveling across the country, change your start interval to 15 minutes or a half hour and use a public Twitter account. (Remember to reboot after making changes to the Launch Daemon). Your friends will be able to track your progress using the Google Maps URL that's tinyURL'ed into each tweet.
Enjoy your newfound location awareness!













Reader Comments (Page 1 of 7)
2-21-2008 @ 4:20PM
Bassir said...
Next, can you make it tell me when I'm hungry or have to go to the bathroom?
Reply
2-22-2008 @ 2:01AM
Lucky888 said...
Bassir,
If it could tell you when you were hungry you would be picking your nose and eating your buggers more often than you do...
2-21-2008 @ 4:23PM
Chris said...
Apple just updated iTunes
Reply
2-21-2008 @ 5:01PM
blinkcowz182 said...
7.6.1 downloading now!
2-21-2008 @ 4:35PM
kirankonathala said...
That was me who bugged Erica for such a solution cos' my friend lost his iPhone in a matter of few seconds and I couldn't seee him cry :( But yeah, thanks a ton Erica :) you rock big time!!
Reply
2-21-2008 @ 4:36PM
Charles said...
Wow.
I've resisted jailbreaking my iPhone so far (and with the SDK coming out in the next eight days (ha!), I still may not), but this is quite tempting.
Reply
2-21-2008 @ 4:57PM
Bassir said...
I've been tempted for months now, in anticipation of the SDK, and now more than ever I'm being tempted... I need third party applications.
2-21-2008 @ 4:43PM
Shannon Hicks said...
OMG! Finally, a decent solution to photo geocaching! My cell can get a signal pretty much anywhere. Just sync the phone data with the picture timestamps, and you're good to go!
Reply
2-21-2008 @ 5:06PM
Michael said...
Okay - pretty cool solution to get your iPhone to send geo data back to you. Let's continue with the theft scenario however:
- Your iPhone gets stolen
- You've setup your iPhone to 'phone' home twice a day (once at 8.00AM and once at 8.00PM)
- Your iPhone was stolen around 10.00 AM
- You wait until 8.00PM for the message and sure enough, it works, you have a location
Now what? The location is approximate from 50 feet to a quarter mile based on cellular triangulation and wifi access points. How are you supposed to locate your phone exactly?
Reply
2-21-2008 @ 5:47PM
Michael Rose said...
Interesting point. 1x a day may be too low for realistic tracking... I would be curious if anyone with a law-enforcement background can comment on the usefulness of nearest-tower data.
2-21-2008 @ 5:57PM
Fritz Laurel said...
I would think you would collect multiple days of data to the point where you can build a usage profile. For that, getting the iPhone to phone home at random intervals would be best. If you can capture someone at home and then at work, for example, you can narrow it down quite a bit.
Maybe you'd have to track them to their neighborhood and then go door to door, asking a neighbor who works at XYZ company or something.
Once you have the perp's house, you might be able to get the cops involved?
Just thinking out loud.
Or, you could just buy some insurance. But, then you wouldn't get to use this awesome idea (I LOVE this idea!).
Cheers,
FL
2-21-2008 @ 6:07PM
Fritz Laurel said...
Of course, all of this assumes the thief doesn't swap SIMs on you or wipe the phone right away...
2-21-2008 @ 5:12PM
WickDC said...
NICE! I think the tracking for friends and geo data back is probably more useful than the LoJack tho. :) Erica - any plans to make a GUI for this? It'd also be super cool if it could also save the location data and timestamp into a local database instead of Twitter. It would be great to have that as GPS data (well, semi-accurate obviously) on a trip to time stamp along with photos. I've held back on purchasing a GPS tracker/saver with this, but there's software to put geocoding into images based on the times from an outside database.
Reply
2-21-2008 @ 5:18PM
Mudassir Azeemi said...
I see this in a way that...
"Welcome to San Francisco International Airport, we serve Starbucks and the best Restaurant in town right on the Airport, for your next meal or a cup of coffe, here is your 10% Discount Coupon"
This is I am expecting to get whenever I will return from my vacation trip to the place where i live & breathe!
Ciao for now,
Mudassir Azeemi
San Francisco, CA
http://www.BonGeek.com
Reply
2-21-2008 @ 5:19PM
YodaMac said...
I guess you'd go to the location and start calling your iPhone and listen for it to ring to know who has it... unless the thief has already changed the ring tone.
Reply
2-21-2008 @ 5:20PM
dansays said...
If you're pinging Twitter, why not have it watch for a special code that would trigger a "stolen/lost" mode, a la Undercover. Instead of just sending geo data, automatically snap and upload photos to Flickr.
Reply
2-21-2008 @ 8:42PM
Michael Rose said...
At the moment, the app is only sending TO twitter, not reading messages from. A trigger message won't work, unfortunately.
2-21-2008 @ 5:26PM
gldfsh419 said...
Yeah... I agree that it's cool, but I'm a bit perplexed on exactly how this will lead to stolen iPhone recovery.
Reply
2-21-2008 @ 5:26PM
Eddie said...
What'd be great is if someone picked this up and set the app to communicate w/ a custom website. Then you could login to the site, and tell the app to update you, say, hourly. Now you have hourly updates on where your iphone is going (creepy?). In bigger cities the maps location works almost exactly (ny here).
Reply
2-21-2008 @ 5:38PM
Barry Brown said...
This seems a pretty complex way of doing what navizon does anyway. It will log where your iphone is and report it back to your website.
-Barry
Reply