ArtStyle ArtStyle - 4 months ago 8
Objective-C Question

How to get a number of unread messages in gmail objective c

This sample allow me to fetch some labels from Gmail interface. The question is: Is it possible to fetch number of user's unread messages in Gmail using same tools like in the sample?

Answer

I'm not very good at objective-c, but you can get every message with the UNREAD-label and check the unread count:

Request

GET https://www.googleapis.com/gmail/v1/users/me/labels/UNREAD?access_token={YOUR_ACCESS_TOKEN}

Response

{
 "id": "UNREAD",
 "name": "UNREAD",
 "type": "system",
 "messagesTotal": 354,
 "messagesUnread": 354,
 "threadsTotal": 320,
 "threadsUnread": 320
}

As you can see, messagesUnread tells me I have 354 unread messages.