通过 Gmail 获取未读邮件数 API

Get number of unread messages via Gmail API

This sample 允许我从 Gmail 界面获取一些标签。问题是:是否可以使用示例中的相同工具获取用户在 Gmail 中的未读邮件数?

我不太擅长 objective-c,但你可以 get every message with the UNREAD-label 并检查未读计数:

请求

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

回应

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

如您所见,messagesUnread 告诉我有 354 条未读消息。