[EDIT: Well, that was quick. There’s now a Cydia extension built exactly for this purpose. It apparently will even restart Sparrow if it crashes, or you restart your phone!]

[EDIT AGAIN: I tried out that extension, and it doesn’t work quite as well as the Backgrounder hack below. For one thing, it seems to break background audio APIs (which I assume will be fixed), but it also doesn’t allow Sparrow to download the contents of messages, like the Bacgrounder hack does. I’m sticking with my method for now.]

Sparrow for iPhone is an awesome new email client for iPhone. It’s clean, sleek, and information-dense. However, as Sparrow explains here, push alerts are conspicuously absent from the app, mostly because of Apple’s limitations. I won’t get into why this is so stupid, but I have found a fairly involved way of making Sparrow behave exactly like the native Mail app, including offline cacheing (which is actually more than any app is allowed to do through normal push). You have to be Jailbroken in order for this to work, which is kind of a drag, but alas, it’s all we’ve got right now.

The first step, obviously, is to download Sparrow and set it up. When you’re in Sparrow and someone sends you an email, you’ll notice that the email comes in immediately, without manually refreshing, and the contents of the message are downloaded into the app. At the same time, the unread badge on the app’s icon reflects the new mail count. These are the keys to this whole thing. We’re going to trick Sparrow into thinking it’s always in the foreground.

From the Cydia store, search for “Backgrounder.” Basically, backgrounder is a utility that can override iOS’s native multitasking and customize it however you like. The app defaults don’t change much about how your phone works, so don’t worry about messing anything up. You may, however, want to turn off the icons that are present on backgrounding apps by default.

The next step is to set up a custom backgrounding scheme for Sparrow. In Backgrounder, select “Overrides” and add Sparrow to the list. Check the “Forced” option. This means that Sparrow will no longer use iOS’s “frozen” app state, and instead keep running all the time as if Sparrow were constantly in the foreground. I also turned off “Fall Back to Native,” which seemed to be unpredictable, at least on my iPhone 4. I chose to leave the backgrounding icons on for a while, just so I could be sure Backgrounder was doing its job and I wasn’t missing any emails.

 

Click the Home button, and your device will respring. When it comes back, launch Sparrow. You’ll notice the “forced” icon up in the status bar, and if you return to the home screen, you should see the black “forced” bubble in the corner of Sparrow’s icon. Now, wait for a new email to come in, and Sparrow will vibrate/play a sound (if that option is turned on in the app), and the app badge will reflect your unread count! If you delete or read a message from another synced machine, the badge will reflect that, too, almost in realtime, just like Mail.app.

Now, I should mention that this could potentially come with a performance hit to your phone. I haven’t noticed any memory or battery issues in the one day I’ve been running this, but your mileage may vary. Even if there were a performance hit, though, I think I would call it a fair trade to be able to run Sparrow as my primary email app. Hopefully Apple will wake up and make this behavior possible through official APIs, but until then, this hack will have to suffice.