Tuesday, July 28, 2009

Sandbox Push Notifications on Hacktivated iPhones

This post reports my finding that push notifications in the sandbox environment don't work on hacktivated iPhones, even with the Push Fix package.

I spent a lot of time developing code for Push Notifications, because I was debugging my code under the assumption that Push Notifications work on my iPhone. I hope this post saves some time for other iPhone SDK developers.

Test Environment
I used an iPhone 2G (hardware model iPhone1,1) which was never activated with AT&T. The phone was connected to the Internet via WiFi, and it had no SIM card in it. My control is a newly bought iPod Touch 2G (hardware model iPod2,1) was activated with iTunes, upgraded to iPhone OS 3.0, and connected to the Internet via the same WiFi router.

The iPhone was jailbroken, hacktivated, and unlocked with Pwnage Tool 3.0, and it received Push Fix from the iPhoneil.net repository. I used AIM (the free edition) to confirm that Push Notifications work on the iPhone.

I used ZergSupport's test suite to collect the push tokens for the iPhone and iPod, and I used imobile's test suite to send the push notifications.

Test Results
The hacktivated iPhone never received notifications from the sandbox (a.k.a. development) servers. It did receive notifications from the production servers. The iTunes-activated iPod received both development and production notifications.

Conclusion
If you're considering developing for the iPhone, and you want to implement and test Push Notifications for your application, you'll need an iTunes-activated device. The cheapest option is probably an iPod Touch 2G.

Motivation
I can't afford an iPhone. I can afford the device, but I can't afford AT&T's plan. On the other hand, I want to address the iPhone's user base, because it consists of wealthy people who spend money easily.

I have an iPhone 2G, from the good days when you could buy one in an Apple store, and not have to deal with AT&T at all. I like testing my application on its EDGE connection, to ensure they behave under the worst-case network connectivity scenario.

10 comments:

  1. This might be related to this: http://www.crunchgear.com/2009/07/21/iphone-push-problem-broadcasts-your-aims-to-random-recipients-could-effect-jailbrokenunlocked-phones/

    ReplyDelete
  2. @mircea: Thanks for the link! I don't think it's the same issue, though.

    In my opinion, what the article above mentions was... expected. It looks like the DevTeam push fix injects someone's push notifications credentials (certificate and key) into a jailbroken device's keychain. Because of that, many people share the same credentials, so they subscribe to the same notifications.

    When developing applications, we use a different set Apple backends for push notifications, called the sandbox. I assume the sandbox operates with different certificates and keys, and the iPhoneIL folks (packaging the DevTeam's fix) didn't bother to deal with sandbox certificates.

    What I said above is an educated guess at this point. I'll know for sure when StockPlay 0.9 gets approved by Apple, and I'll be able to compare push tokens for sandbox and production environments.

    ReplyDelete
  3. I never really thought about it but you can just buy an ipod touch and use that as a development platform for the iPhone if you dont want to fork over all the money or have to go with ATT and get it subsidized.

    I wonder if that's why Apple is giving away free ipod touches to college students instead of printers now =p haha (probably not since they loose less money giving away something they produce rather than something from HP).

    ReplyDelete
  4. @Peter: you can use an iPod touch as a development platform, if you don't intend to use the missing features (vibration, camera, GPS, compass). Another issue to be aware of is that the iPod Touch 2G has a faster processor than the iPhones, so the app will be slower for your customers.

    I believe Apple's been giving away iPods for their back-to-school sales for 3 years now. I think they're using the offer to clear their inventory, because Steve Jobs announced new iPods every time this sale happened. Furthermore, you can't use the back-to-school discount on new-generation iPods, even if they are announced before the sale ends.

    I wish your thoughts were correct. Sadly, based on what I'm reading nowadays, I think Apple knows they have the leading mobile platform, and they're treating developers like crap because of that.

    ReplyDelete
  5. You can try to fake notifications like here:
    http://networkpx.blogspot.com/2009/06/sending-push-notification-locally.html

    ReplyDelete
  6. @Anonymous: thank you for your link! The method described there is definitely useful for manually testing an application, without the hassle of getting certificates from Apple.

    For my case, I wanted tests that cover the entire APNs infrastructure. I hope to write about that sometime soon.

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. @dave: I removed your comment because of the irrelevant link. Please talk to me if you believe you had a good reason for that link and I missed it.

    ReplyDelete
  9. It really amaze me hoe this hacktivated thing fails to work on certain applicatios. I also think that its not possible for everyone to afford Iphone and AT&T together but in future it will be quite cheap.

    ReplyDelete