I have implemented code in java for receiving gmail push notifications. It is working perfectly fine for the mail id, in which I have created the project, topic and subscription. The notifications are published to my mentioned URL and I can fetch the data of the notifications. But I want to receive the notifications for multiple users on that same topic and same push end point url, that I have used for one mail-id. Is that Possible?.
Asked
Active
Viewed 631 times
2

Imtiaz Hussain
- 203
- 2
- 15
-
Suggesting could be quite difficult because your code is missing – James Z Oct 09 '18 at 15:58
1 Answers
2
Watch request To configure Gmail accounts to send notifications to your Cloud Pub/Sub topic, simply use your Gmail API client to call watch() on the Gmail user mailbox similar to any other Gmail API call. To do so, provide the topic name created above and any other options in your watch() request, such as labels to filter on. For example, to be notified any time a change is made to the Inbox:
Request:
POST "https://www.googleapis.com/gmail/v1/users/{UserId}/watch"
Content-type: application/json
{
topicName: "projects/myproject/topics/mytopic",
labelIds: ["INBOX"],
}
Response
{
historyId: 1234567890
expiration: 1431990098200
}
Each watch request is for a single user. If you want it for more then one user then you will have to set it up to watch each user you are interested in.

Linda Lawton - DaImTo
- 106,405
- 32
- 180
- 449
-
I know this thread is old but is there any way yo track the watched emails. What which emails have been watched for the topic? – sazanrjb Jul 08 '20 at 12:13
-