![]() Responding to notificationsĪll notifications need to be acknowledged. The Cloud Pub/Sub Subscriber Pull Guide for If you have configured a pull subscription instead, refer to the code samples in To get the change details for the user since their last known That decodes to a JSON object containing the email address and the new mailbox That message.data field is a base64url-encoded string The HTTP POST body is JSON and the actual Gmail notification payload is in the Subscription: "projects/myproject/subscriptions/mysubscription" ![]() This is the publish time of the message. This is a Cloud Pub/Sub message id, unrelated to Gmail messages. This is the actual notification data, as base64url-encoded JSON.ĭata: "eyJlbWFpbEFkZHJlc3MiOiAidXNlckBleGFtcGxlLmNvbSIsICJoaXN0b3J5SWQiOiAiMTIzNDU2Nzg5MCJ9", If you have configured a push subscription, a webhook notification to your Will receive a notification message describing the change. Whenever a mailbox update occurs that matches your watch, your application The watch response also has an expirationįield with the timestamp for the watch expiration. Renewing mailbox watchħ days or else you will stop receiving updates for the user. The setup is correct and for help with debugging topic and subscription issues. Refer to theĬloud Pub/Sub documentation to confirm that The source of the problem, which is typically with the setup of theĬloud Pub/Sub topic and subscription. If you receive an error from the watch call, the details should explain Immediately be sent to your Cloud Pub/Sub topic. Prior to this historyId, refer to the sync guide.Īdditionally, a successful watch call should cause a notification to HistoryId will be notified to your client. With the current mailbox historyId for the user. ers().watch(userId='me', body=request).execute() 'topicName': 'projects/myproject/topics/mytopic' TopicName: "projects/myproject/topics/mytopic", For example, to be notified any time a change is made to the Inbox: To do so, provide the topic name created above and any other optionsįilter on. ![]() On the Gmail user mailbox similar to any other Gmail API call. To configure Gmail accounts to send notifications to your Cloud Pub/Sub topic, Once the initial Cloud Pub/Sub setup is finished, configure Gmail accounts to Using the Cloud Pub/Sub Developer Console permissions interfaceįollowing the resource-level access control instructions. To do this, you need to grant publish privileges You can do this This is how your application will receive notifications for updates.Ĭloud Pub/Sub requires that you grant Gmail privileges to publish notifications Configure the subscription type toīe either a webhook push (i.e. ![]() Create a subscriptionĪ subscription to the topic that you created. We recommend that you use a single topic for all Gmail API push notificationsįor your application, due to Cloud Pub/Sub limits Is the Project ID listed for your project in the Google Developers Console). matching projects/myproject/topics/*, where myproject The topic name can be any name you choose under your Using your Cloud Pub/Sub client, create the topic In order to complete the rest of this setup, make sure you fulfill the Including webhooks and polling on a single subscription endpoint. This allows notification via a variety of methods The Gmail API uses the Cloud Pub/Sub API to deliver Sync guide is still the recommended approach to retrieve installed apps, mobile devices, or browsers), the poll-based Note: For notifications to user-owned devices Whenever a mailbox changes, the Gmail API notifies your backend It allows you to eliminate the extra network and computeĬosts involved with polling resources to determine if they have changed. You can use this feature to improve the performance The Gmail API provides server push notifications that let you watch forĬhanges to Gmail mailboxes.
0 Comments
Leave a Reply. |