Hi,
I'm using web push component, and I have configured and the subscription and pushnotification but I'm the only person who see the notifications :
is there a way to display the same notification for the other users who use the application ?
thanks for your help
Hi @you asen ,
"you and your colleague have the demo opened on your browsers. so if you send an notification, is your colleague suppose to recieve the notification?"
With the demo implementation, the answer is NO. When you click "Push Notification" button on the demo, you are pushing a notification to that specific device. The demo is just a simple example of the component capabilities, you can use it to implement you own logic to push notifications to multiple devices.
"To send a notification for a user, the user need first to subscribe on the device he is using.=> I have no idea how to do it with this component. "
This is done on the demo by clicking on the button "Create Subscription". You need to see what is done on this button, get the subscription information that is returned by the subscription method (shown on the demo on User Subscription field), and stores this information to use the way you want to. This information is used to push the notifications latter.
"what I'm looking for is, when I click on the push notification button, all the users who open the app with thier browser should should see the notification. "
Is it possible to do something similar on what you just described, but you need to create all the logic to support it. As I mentioned, not "all users who open the app will receive the notification", but all users that have subscribed to will receive... You can implement something that runs the subscription silently when the user opens the application for example, so, you will have the users subscribed. Another point is that you need to send one message for each subscription, so when sending the notifications you would need to iterate over all users subscriptions to push a message to each of them.
I recommend you to take a look on how push notification works first, to confirm that this is what you are looking for - maybe a more simple in-app notification can be enough. After that, take a look on some vendors that implements it for you (some features are not free, so, analyse it carefully), such as Firebase and OneSignal. Tools like these offers some capabilities that reduces the amount of development on your side - and for this you will probably pay for use it - while this component use pure web native methods, so it is free to use, but you need to implement all the logic and resources around it.
Hope this helps.
Let me know if you have more questions.
Many thanks for your reply .
You can implement something that runs the subscription silently when the user opens the application for example, so, you will have the users subscribed. Another point is that you need to send one message for each subscription, so when sending the notifications you would need to iterate over all users subscriptions to push a message to each of them
=> you mean for every use subscribed I need to save :Endpoint and P256dh and Auth and into the Notification table then iterate overt then to send notification ?
Yes.
thanks a lot, I will try then I will get you back
Not sure if I understood your question, but each notification is sent to a unique user/device.
To send a notification for a user, the user need first to subscribe on the device he is using; it is up to you how to get and store the subscription information (on the demo you have an example on how to subscribe - button "Create Subscription").
In order to show the notifications, the user needs to consent on gettings notifications from that system; it is another step you need to add somewhere on your application (you can see an example on the button Request Permission.
thanks for your reply.try the demo(.oml) , and image you and your colleague have the demo opened on your browsers. so if you send an notification, is your colleague suppose to recieve the notification or No ? if NO so I understand that the component does not support this feature, if it is Yes, how I can achieve that because I have tried the demo with my colleague and it didn't work(when I send a notification, he recieves nothing).
To send a notification for a user, the user need first to subscribe on the device he is using.=> I have no idea how to do it with this component.
and finally, what I'm looking for is, when I click on the push notification button, all the users who open the app with thier browser should should see the notification.
I will be glad if you can help please.
thanks
@you asen, I was trying out Tiago's asset to see if it would work for me. As a quick test, I added support for the OS Users Module and storing the subscription in the database so that it could be sent out to the selected user. It'd be easy to loop through that to send to all subscribed users.