如何使用gmail api检测读取未读邮件?

时间:2016-02-12 07:12:45

标签: ios objective-c gmail gmail-api

我正在开发一个邮箱应用程序,我收到以下响应作为GTL消息的“GTLGmailMessage”对象,如下所示: - 我已经阅读了api文档,但我无法找到任何解决方案。

有没有办法检测邮件被读取或未读。

{
historyId = 80237;
id = 152589a56bea2515;
internalDate = 1453185455000;
labelIds =     (
    INBOX,
    IMPORTANT,
    "CATEGORY_UPDATES"
);
payload =     {
    body =         {
        data = DQp———— — dG9bmtzIQ0K;
        size = 732;
    };
    filename = "";
    headers =         (
                    {
            name = "Delivered-To";
            value = "hussain@walkover.in";
        },
                    {
            name = Received;
            value = "by 10.37.100.68 with SMTP id y65csp2443890ybb;        Mon, 18 Jan 2016 22:37:35 -0800 (PST)";
        },
                    {
            name = "X-Received";
            value = "by 10.13.239.129 with SMTP id y123mr16831747ywe.167.1453185455680;        Mon, 18 Jan 2016 22:37:35 -0800 (PST)";
        },
                    {
            name = "Return-Path";
            value = "<noreply@github.com>";
        },
                    {
            name = Received;
            value = "from github-smtp2b-ext-cp1-prd.iad.github.net (github-smtp2-ext3.iad.github.net. [192.30.252.194])        by mx.google.com with ESMTPS id q63si16585388ywb.331.2016.01.18.22.37.35        for <hussain@walkover.in>        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);        Mon, 18 Jan 2016 22:37:35 -0800 (PST)";
        },
                    {
            name = "Received-SPF";
            value = "pass (google.com: domain of noreply@github.com designates 192.30.252.194 as permitted sender) client-ip=192.30.252.194;";
        },
                    {
            name = "Authentication-Results";
            value = "mx.google.com;       spf=pass (google.com: domain of noreply@github.com designates 192.30.252.194 as permitted sender) smtp.mailfrom=noreply@github.com;       dkim=pass (test mode) header.i=@github.com;       dmarc=pass (p=NONE dis=NONE) header.from=github.com";
        },
                    {
            name = Date;
            value = "Mon, 18 Jan 2016 22:37:35 -0800";
        },
                    {
            name = "DKIM-Signature";
            value = "v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1453185455; bh=PQFrfD7nxfJCQgsdom7s6/TMtuIlEPwr4GKz/BVEYNE=; h=From:To:Subject:From; b=PbKfqrQfPtJzh2YsK2RqLPahAYL8Wk40aW1GnqZqNCZp0dehGTRCByYDg4HT93m89\t NK+BbCDbcSgkiII6NnBildbsorKfenoVE2jTS21fllusq1Oflmyayo1GyRvGOkFEd1\t WCgQlsicXhXniFDza60ibwwcABXyB/yVCcnrrpGk=";
        },
                    {
            name = From;
            value = "GitHub <noreply@github.com>";
        },
                    {
            name = To;
            value = "hussain@walkover.in";
        },
                    {
            name = "Message-ID";
            value = "<569dd9af5be8b_5b613f8adf71f29c19092@github-lowworker7-cp1-prd.iad.github.net.mail>";
        },
                    {
            name = Subject;
            value = "[GitHub] Subscribed to SendOTP/iOS notifications";
        },
                    {
            name = "Mime-Version";
            value = "1.0";
        },
                    {
            name = "Content-Type";
            value = "text/plain; charset=UTF-8";
        },
                    {
            name = "Content-Transfer-Encoding";
            value = "quoted-printable";
        },
                    {
            name = "X-Auto-Response-Suppress";
            value = All;
        }
    );
    mimeType = "text/plain";
    partId = "";
};
sizeEstimate = 2601;
snippet = "Hey there, we&#39;re just writing to let you know that you&#39;ve been automatically subscribed to a";
threadId = 152589a56bea2515;

}

如何检测天气邮件已读或未读。

先谢谢。

2 个答案:

答案 0 :(得分:3)

您可以在回复中检查UNREAD - 数组中的labelIds - 标签。

请求

GET https://www.googleapis.com/gmail/v1/users/me/messages/152d4596db9906f8

<强>响应

{
 "id": "152d4596db9906f8",
 "threadId": "152d4596db9906f8",
 "labelIds": [
  "SENT",
  "INBOX",
  "IMPORTANT",
  "UNREAD"
 ],
 "snippet": "Cool message, buddy.", ...
}

答案 1 :(得分:3)

消息的已读/未读状态由UNREAD标签的存在表示。

enter image description here

您可以在以下链接

中找到有关管理标签的信息

Managing Labels