Google Apps - Gmail API的通知功能

###Gmail API Google终于提供了Gmail Push Notification功能了。 Synchronizing Clients with Gmail

Keeping your client synchronized with Gmail is important for most application scenarios. There are two overall synchronization scenarios: full synchronization and partial synchronization. Full synchronization is required the first time your client connects to Gmail and in some other rare scenarios. If your client has recently synchronized, partial synchronization is a lighter-weight alternative to a full sync. You can also use push notifications to trigger partial synchronization in real-time and only when necessary, thereby avoiding needless polling.

正如Google所说,之前我们为了同步用户的邮件信息或者新邮件通知的时候,服务器端需要不停的去Google调用用户当前的邮件信息。现在通过它新提供的push notification功能,服务器不需要主动去获取,而是只需要在那等待Google主动发送请求到我们服务器上即可。

###注意事项 在同步邮件的时候需要注意下面几个方面:

  • 首次需要全局同步,利用message.list,batch requestmessage.get来同步用户的全部邮件信息。
  • 之后利用Users.watch开启监听并获取最新的historyId并保存到本地
  • 当Google主动push一个请求过来时,判断获得的historyId是否比Client.historyId新。如果是的话,就通过Users.history.list(Client.historyId)来获取差异部分。

转载于:https://my.oschina.net/destroy001/blog/526815

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值