I\'m trying to understand how the Gmail API works. My goal is to retrieve a list of all of a user\'s emails in their inbox, downloaded to an NSArray
.
Current
The basic workflow is correct and you have multiple ways to achieve what you want:
The Gmail API which is a RESTful API that can be used to access Gmail mailboxes and send mail. The API supports many of the basic operations available through the Gmail user interface like reading, composing, and sending mail. It also lets you manage labels on threads and messages and query for specific messages and threads.
You can write your own Objective-C wrapper around the API to make the correct HTTP request to the differents endpoints described in the API reference but it's a lot of work, you have to write everything you need, error management, validation, etc...
You can use the Google APIs Client Library for Objective-C recommended for accessing JSON-based Google APIs for iOS and Mac OS X applications. This API include support for many Google products including Gmail.
IMAP and SMTP protocols are supported by Gmail and include OAuth 2.0 authorization.
It seems to me you're looking for the easiest way to interact with Gmail mailboxes so the Gmail API is the best choice for authorized access to a user's Gmail data.
I would go for the Google APIs Client Library for Objective-C so you won't have to write your own wrapper around the API and can use it out of the box.
You saw the python example code to retrieve a page of threads:
threads = gmail_service.users().threads().list(userId='me').execute()
The Google APIs Client Library for Objective-C will give you methods to do the same thing with multiple options like possibility to include the spam & trash folder in results, maximum number of results, search for a thread matching a specific query, etc.
+ (id)queryForUsersThreadsList;
All actions described in the API reference are supported by Google APIs Client Library for Objective-C.