Saturday, August 8, 2009

Gmail push notification on iPhone

This morning I saw that an iPhone app appeared on the app store that provides iPhone push notifications for Gmail. After looking into this a bit it looks like the GPush app sends your username and password to the GPush server and from their servers keeps an IMAP IDLE connection to Gmail open. Whenever Gmail signals a new email to the GPush server, GPush triggers an iPhone push notifications via Apple's Push Notification Service (APNS).

I really don't like the idea of some unknown company having my Gmail credentials and being logged into my gmail account all the time, so I built a proof-of-concept of the same thing that I can run on my own server. I used the following code:

Python imaplib2 from

example IMAP IDLE server from

APNS code based on examples from Apple iPhone developer forum postings

You can find the proof-of-concept code for client and server on github

To try this you need to have an iPhone developer account, create a Push Notification provisioning profile and have a server that runs python 2.6.


Cape Cod Todd said...


no offense, but what about the regular, common folk, like me who don't know anything about provisioning, servers or python? c'mon man, give me an app, not a complex scientific jargon that I have no hope of converting. you're a few technology floors above where the rest of us live.

Keith said...

Thank you very much for the proof-of-concept.

I am at the last step but don't know how to start the server. Could you please explain more?

Gunnar Evermann said...


just run something like


on your server. Make sure you set the userame and password in the script.

Xander said...

Is there a way you could use this to monitor multiple gmail accounts? Cuz like I have a lot of different ones from years of making new ones and it'd be awesome if I could have just one python script monitor and push all of them to me! (BTW i'm wayyyy new to python) Please reply! Thanks, and great script!!