如何从我的 Gmail 帐户接收推送通知?
我想编写一个监视邮箱(最好是 Gmail 邮箱)的应用程序。简而言之,我的问题是如何收听传入的电子邮件?我总是可以继续提取电子邮件,但我担心这不能很好地扩展。
iOS 如何使用 Gmail?我认为他们正在使用 Exchange 协议,但我不确定。有人知道如何做吗?是否有一个解决方案已经做了类似的事情?我只需要一个钩子。
谢谢!
I'd like to write an application which monitors a mailbox (ideally a Gmail mailbox). In brief, my question is how do I listen to incoming emails? I could always keep pulling emails but I am afraid that this doesn't scale very well.
How does iOS do it with Gmail? I think they are using Exchange protocol, but I am not sure. Does anybody have an idea on how to do it? Is there a solution which already does something similar? I just need a hook.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
用于监控 Gmail 或 Google Apps 收件箱的最通用的“API”是 IMAP 协议。这里有一些关于此的信息:
适用于桌面客户端的 Gmail IMAP OAuth
适用于 Google Apps 收件箱(不是一般消费者 Gmail 帐户) ),您还可以使用 Gmail 收件箱供稿,它提供 Google Apps 收件箱中未读邮件的 AtomPub XML 供稿:
http://code.google.com/apis/gmail/docs/inbox_feed。 html
The most universal "API" for monitoring a Gmail or Google Apps inbox is the IMAP protocol. There's some information about this here:
Gmail IMAP OAuth for desktop clients
For Google Apps inboxes (not general consumer Gmail accounts), you can also use the Gmail Inbox Feed, which provides an AtomPub XML feed of unread messages in a Google Apps inbox:
http://code.google.com/apis/gmail/docs/inbox_feed.html
GMail 的“API”是 IMAP。
在 IMAP 中,IDLE 功能用于告诉服务器在邮箱发生更改时通知客户端。
IDLE 在 RFC 2177 中定义 IDLE 是可选的 IMAP 功能,因此这可能会也可能不会在其他 IMAP 服务器上工作。
The "API" to GMail is IMAP.
In IMAP the IDLE feature is used to tell the server to notify the client when there are changes to the mailbox.
IDLE is defined in RFC 2177 IDLE is an optional IMAP feature so this may or may not work on other IMAP servers.
如果您只想与 Gmail 对话,您可以使用他们的 REST API,并且它支持推送通知(例如 webhooks):
https://developers.google.com/gmail/api/guides/push
但同样,这是 Gmail 特定的 API,它可能适合您的要求,也可能不适合您的要求。如果您只专注于 Gmail,那么在网络/移动类型环境中使用可能比 IMAP 之类的工具更容易、更好。
If you just want to talk to Gmail, they have a REST API you can use and it supports push notifications (e.g. webhooks):
https://developers.google.com/gmail/api/guides/push
But again this is a Gmail-specific API, which may fit you requirements or not. If you are fine just being specific to Gmail it is likely easier and better to work with from a web/mobile type environment than something like IMAP.