I've done all steps required and I'm successfully receive push notifications on my server endpoint. I want to get message text snippet and sender to be displayed in push notification but this requires a call to history API with valid user token. Moreover I want to filter this to push only new messages not all Inbox activity. In what way should I do this to provide safe experience. Should I store Gmail auth tokens on serverside and make calls from there and then push a notification with proper message data to users ? Is token storing and handling proper and safe on my server ? Or maybe there is another way ?
Related
I had just replaced my app with supabase from firebase in flutter app.
Firebase has firebase_messaging that provide push notification to device token.
Is there any facilities to create function in supabase and send notification to selected user with device token while changing in database.
If yes than please suggest some function else suggest some method to send notification.
Supabase does not provide a mechanism to send push notifications at this point, so you can use FCM or other push notification sending services to send them out to the users.
If you are going with FCM, you can setup your own backend using Firebase cloud functions or other backend service that you prefer to send the notifications from.
Typically, you would want to send push notifications to your users when there is some kind of change in the database, like when there was a new message sent or someone liked a post. You can listen to these events using Supabase database webhooks. With database webhooks, you can send your backend a request whenever you receive certain data change happening in your database.
Using these three tools, I'm trying to think of the best way to notify a user when the other user in a chat sends them a message (using APNs).
Would it be reasonable to store (and always update to newest value) the fcm registration token as a field under the user document in firestore, then in cloud functions, create a trigger to respond to new messages being sent (where each message is a document)? Then in order to determine which device to send it to, we use the registration token field?
Is there a better way to do this?
I have java server application. And I need to monitor a lot of gmail accounts to be able to send push notifications to mobile devices about new Inbox messages.
I need to know sender email and message subject to send push notification.
And I tried Gmail push notifications system (webhooks option)
If I understood everything correctly in order to get needed info for each new message for each user there is a following scenario:
Google sends me email and history id via https request.
I call history API and get new message ids for user
I request message info by message id
That means that I need 2 additional requests for each new message of each user. And it looks quite hard if server needs to handle several new messages each second. And I still don't see other way.
Is there any way to make it shorter? (e.g. to make google send me not only history id but needed new message details or at least make one additional request, but not two)
Thanks!
We tried using Push notifications but the volume of requests generated has meant that we poll on a timed basis instead. It is worth noting that you will get Push notifications for any change to the message such as a label change, a read status change etc. As you say there are many requests.
If you need the notifications real-time I don't see how you can avoid the process that you outline.
If you don't need it real-time then you can poll or at the least check for Push notifications per account on a timed basis and if some have been received retrieve any new messages in a batch rather than a single request.
I was facing the same problem. History API was not giving recent messageId. I solved this problem by hitting THREAD API where i set Q = last 5 min timestamp.
Webhook push notification is helping to notify a new mail has come. After i get all messages last 10 min with THREAD API.
This is the first time that I approach the push notification service and I'm little bit confused. I 'd like to have just some conceptual help, not code.
I need to build an app that should receive and register for different kind of notifications. For instance in my app I'd like that users could register for PROMO notifications category and NEWS notifications category, I'd like that they could choose which one they want to be notified.
Reading the Apple doc, that was not so clear to me, it seems that once the app device is registered I receive just one token and seems impossible to receive more tokens for different kind of registration(NEWS and PROMO for instance), because the token is related to the app and the device. Is that correct?
The other thing that is not so clear to me is, if a device is registered for a specific notification is it possible to send the notification only to a set o devices?
If nothing of that is offered by Apple Push services do you think that is possible to manage everything like that:
-I register the app device for notification if (PROMO || NEWS) are selected
-I get the token
-I send the token to my server giving also as additional info about the service which the user wants to subscribe
-The server (provider) register the token and the kind of subscription (PROMO || NEWS)
-Later when I have a notification to push I ask the server all the tokens registered for that specific category and then I send the notification only to those devices registered for that category.
Thanks for helping me out I'm really confused.
"Reading the Apple doc, that was not so clear to me, it seems that once the app device is registered I receive just one token and seems impossible to receive more tokens for different kind of registration(NEWS and PROMO for instance), because the token is related to the app and the device. Is that correct?"
YES
The other thing that is not so clear to me is, if a device is registered for a specific notification is it possible to send the notification only to a set o devices?
YES, you need a DB where you connect a Push Token with the related Services (promo | news). If you have a new Promo Push Message you send the message to all related token. on the app site, everytime the user change the categorie (promo / news) you should prpvide these infos to your service with the push token.
These are all problems that you have to solve yourself on the server side. The push service simply provides a means to send a single message to a single device. You have to figure out yourself which messages you want to send to which devices. Each message has to be sent individually, there's no way to "broadcast" a message to all your users directly.
You could think of the push tokens as email addresses – of course, one email address might be subscribed to different newsletters from the same publisher, but it's the publisher's job (yours) to figure out whom to send which newsletters, not the email provider's (Apple's).
You should think of the push notification registration like my I send the user push notifications. Not what kind of push notification can I send the user.
Then you need to do serverside filtering on you categories, like the ones in your example promo and news.
The perferance of the user should be stored on your server, so you will know what kind of notification to send to which user.
I want to send push notifications to the application users and i can send to all users, but i want to select users also. How can i do that?
If you are currently able to send push notifications to all of your users, you're obviously storing their device tokens somewhere. If you want to send a notification to a single user, you just need to determine which token is theirs (possibly by associating information with it in the database—e.g. their email) and send a single notification to APNS.