gmail API watch webhook: how to get the user-id - push-notification

We need to use push notifications for many users, using watch Gmail API call.
The watch response we should get on the webhook does not contain any information about the user for which the webhook has been called.
The problem is that according to Users.history: list
I cannot get messages without user-id.
How am I supposed to get user-id from the watch webhook?
OR
Is it possible to call something similar to "Users.history: list" without the need to have user-id?
Thanks for your support,
Adrien

Edit from info in link in comment
If you check the Push Notifications you will see that the response from the server contains a data field.
// This is the actual notification data, as base64url-encoded JSON.
data: "eyJlbWFpbEFkZHJlc3MiOiAidXNlckBleGFtcGxlLmNvbSIsICJoaXN0b3J5SWQiOiAiMTIzNDU2Nzg5MCJ9",
The HTTP POST body is JSON and the actual Gmail notification payload is in the message.data field. That message.data field is a base64url-encoded string that decodes to a JSON object containing the email address and the new mailbox history ID for the user:
{"emailAddress": "user#example.com", "historyId": "9876543210"}
Data contains the email address of the user.
Note I don't have the power to test this I am just reading the documentation. I don't have a server set up to retrieve these notifications.

user-id is your email, which is used to subscribe push notification

Related

get all notifications sent to a user

I'm using FCM FirebaseMessaging to send push notifications to user of my app.
Is there a way to get all notifications sent to one single user or I have to store them in Firestore db?
It's not entirely clear to me what you mean by "get all notifications sent to one single user". But if you're trying to get a history of all messages previously sent to a user via the FCM API, that's not possible. FCM doesn't remember anything about messages previously sent. You have to keep that record yourself, if that's what you need.

Firebase messageId

I'm sending push notifications by topic using firebase. The response I get looks like this { messageId: 'mymessageid'}
I can't find anywhere I can use this ID to look up information on the notification I sent. I've been through the docs for both client and server side firebase libraries.
Is there a way to use the messageId returned from a send to topic to look up information about the notification's status?

Web Push Notification

I'm having some series of questions about implementing push notifications. The things are,
I am using Angular for my frontend where am sending my subscription value which is of an object type with key keys like endpoint, auth, etc (is this will be same for every device like mobile, or some other browsers).
Does all the data in that subscription object is mandatory? or only endpoint.
If a user is logged in with more than 10 devices, do I need to store subscription values for each device? is it how it works? Or should I store the last logged in device's subscription value? If so then the rest of 9 won't get any notifications.
If you are storing all the loggedin Device's subscription value, then is a user logged in more than one browser will he get the notification in each browser? Is it a standard practice?
Suggestions are welcome, any standard practices will be helpful.
Thanks in advance
subscription object has the same format for every web device/browser
yes, for more, see the documentation
When we want to send a push message to a user with a payload, there are three inputs we need:The payload itself.The auth secret from the PushSubscription.The p256dh key from the PushSubscription.We've seen the auth and p256dh values being retrieved from a PushSubscription but for a quick reminder, given a subscription we'd need these values:
each device has it's own endpoint and auth keys, so if you want to send push to every device user logged in, you need to store all of them
yes, user gets notifications for all browsers, if you call them.( you're making a post request to device's endpoint )

CloudKit Record creation push notification

I am receiving a notification from CloudKit when a record with 'message' field is created. I would like to show to the user on the lock screen the content of the message. could you help me with that.
You have to deliver a Local Notification to the user. You should read the Apple's guide about this topic.
You could send this notification inside the didReceiveRemoteNotification function in AppDelegate class
The way to process the userInfo dictionary received as a parameter must be processed with CKNotification class initialiser.

Can I send push notification using custom_ids not FCM registration-id from my server?

If we want to send message to different device we need to specify their registration_ids in https://fcm.googleapis.com/fcm/send. Is there some API where we can register users unique user_id and send messages using that user_id?
My use case is, I am using Parse for notification and if there are 5 people in a chat, we send notification to those 5 people if there is some activity in the chat. We are already storing the user_id in our database. Now if there is some API where I can specify the registration_ids and user_id. And then later just use user_id instead of storing registration_ids in our database.
If you plan on using FCM for the push notification, short answer is No.
What is required in FCM for you to send to a single or multiple device(s) is/are the registration token(s) and by using the corresponding parameters to, registration_ids in the payload to send it to them.
Other details is pretty much covered by #FrankvanPuffelen's comment.

Resources