views:

426

answers:

3

I want to write a perlscript on my iPhone that is able to give me a heads up at certain points so I'm wondering how I would go about doing that. Is there a way to get a message through the gui from a script running in the background? I've been looking without much luck. I had a thought about inserting a fake sms into the sqlite db as a last resort but it seems somewhat unlikely that it would work. It would be nice to be able to make a push notification style popup appear but that might too much to ask. Any ideas?

+4  A: 

For reasons of security and stability, Apple does not allow scripting languages on the iPhone. You can run them on a jailbroken phone but I'm given to understand it's a hassle.

From the Apple Push Notification Programming Guide:

Note: On a desktop system, a background process is often the means whereby users are informed of downloadable data for an application that currently isn’t running. But on a device such as the iPhone, background applications are, for performance and security reasons, prohibited. Only one application may be executing at a time.

The iPhone is a secure and reliable phone first and a computer second. Computing is sacrificed to ensure a reliable phone.

TechZen
Yeah it is jail-broken. And I have installed perl and made some scripts so that part is done. I just want to know if there is a way to talk to the gui directly or indirectly.
henrik
There are no scripting hooks built into the iPhone API. However, Objective-C is very open to scripting so it might be possible to whip something up. There are 3rd party scripting tools for MacOs such a F-script that give complete access to all Objective-c APIs but that don't depend on any special hooks within the API itself. You might look at F-script which IIRC is open source and see how they do it. Then you could try to apply that to the iPhone OS.
TechZen
Ok, I'll take a look. Thanks!
henrik
+1  A: 

Do you want information from your phone itself or from an outside source? If you want information from an outside source, you could set up a Perl script on a computer to e-mail yourself notifications (see Sending Email with Perl Best Practice).

molecules
I would really prefer to have the iphone do all the work but you make a good point, guess I could resort to that if nothing else works.
henrik
+2  A: 

I found a solution I liked so I decided to share it. I found an app for jailbroken iPhones called GriP - Growl for iPhone. Which changes the way push notifications and other messages are handled. It also makes it possible to send messages from the command line via something along the lines of:

/usr/bin/GriP -t "Title" -d "Description"

It has worked great so far. Thank you for your help TechZen and molecules.

henrik