you asen
Rank: #4900
[Web Push] How to display web notifications
18Views
6Comments
Solved
Question
Forge Web
Web Push
Forge component byTiago Resende
2
Published on14 Feb 2024
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
9 days ago Copy link to post
Tiago Resende Rank: #607 Solution 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. 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. 8 days ago Copy link to comment 3 replies Last reply 8 days ago Show thread Hide thread you asen Rank: #4900 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 ? 8 days ago Copy link to comment Tiago Resende Rank: #607 Hi @you asen , 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. Hope this helps. 9 days ago Copy link to comment 1 reply 8 days ago Show thread Hide thread you asen Rank: #4900 thanks for your reply. To send a notification for a user, the user need first to subscribe on the device he is using. 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 WebPushDemo.oml 8 days ago Copy link to comment Tiago Resende Rank: #607 Solution 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. 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. 8 days ago Copy link to comment 3 replies Last reply 8 days ago Show thread Hide thread you asen Rank: #4900 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 ? 8 days ago Copy link to comment
=> I have no idea how to do it with this component. "
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).
=> I have no idea how to do it with this component.
=> I have no idea how to do it with this component. "
Log in to Answer
Log in to AnswerLog in to Follow