views:

86

answers:

1

Is there an easy way to check a user's Gmail unread count from Cocoa Touch? I'm not interested in sending or reading mail messages. I just want to periodically poll for the unread count. If there is a way, could you please be as specific as possible in your answer?

EDIT: I changed the question from asking about just Cocoa to Cocoa Touch. Also, I'd like to be able to poll for any Gmail account, not just those on Google Apps domains. There is a Gmail Feed API (http://code.google.com/apis/gmail/docs/inbox_feed.html), but the docs say "Note: This feed is only available for Gmail accounts on Google Apps domains".

+2  A: 

You can use the PubSub framework to subscribe to an atom feed exposed by the Gmail Feed.

For the inbox, you would subscribe to: https://mail.google.com/mail/feed/atom/inbox E.g.:

PSClient *client = [PSClient applicationClient];
NSURL    *url    = [NSURL URLWithString:@"https://mail.google.com/mail/feed/atom/inbox"];
PSFeed   *feed   = [client addFeedWithURL:url];

[feed setLogin: username];
[feed setPassword: password];
diciu
Thank you. The Gmail Feed docs say "Note: This feed is only available for Gmail accounts on Google Apps domains". I'm looking for a way to poll the unread count for any Gmail account.I tried the feed in my browser and it seemed to work even though I have a normal Gmail account (no Apps), so I'm a bit confused. It looks like this answer works right now, but might Gmail turn it off for non-Apps accounts in the future?
sam
I up-voted your answer, but realized that my question should have been for Cocoa Touch, not just Cocoa. I believe PubSub is not yet available on iOS.
sam