[Web Push] How to display web notifications (2024)

[Web Push] How to display web notifications (1)

you asen

Rank: #4900

[Web Push] How to display web notifications

18Views

6Comments

Solved

Question

Forge

Web

[Web Push] How to display web notifications (2)

[Web Push] How to display web notifications (3)

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 :

[Web Push] How to display web notifications (4)

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

[Web Push] How to display web notifications (5)

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.
=> 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.

See solution in context

[Web Push] How to display web notifications (6)

[Web Push] How to display web notifications (7)

3 replies

Last reply 8 days ago

Show thread

Hide thread

[Web Push] How to display web notifications (8)

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

[Web Push] How to display web notifications (9)

Tiago Resende

Rank: #607

Solution

Replying to you asen's comment on 11 Apr 2024 10:07:28

Yes.

8 days ago

Copy link to comment

[Web Push] How to display web notifications (10)

you asen

Rank: #4900

Replying to Tiago Resende's comment on 11 Apr 2024 10:14:43

thanks a lot, I will try then I will get you back

8 days ago

Copy link to comment

[Web Push] How to display web notifications (11)

Tiago Resende

Rank: #607

Solution

Replying to you asen's comment on 11 Apr 2024 10:07:28

Yes.

See solution in context

8 days ago

Copy link to comment

[Web Push] How to display web notifications (12)

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

[Web Push] How to display web notifications (13)

1 reply

8 days ago

Show thread

Hide thread

[Web Push] How to display web notifications (14)

you asen

Rank: #4900

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

WebPushDemo.oml

8 days ago

Copy link to comment

[Web Push] How to display web notifications (15)

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.
=> 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.

8 days ago

Copy link to comment

[Web Push] How to display web notifications (16)

[Web Push] How to display web notifications (17)

3 replies

Last reply 8 days ago

Show thread

Hide thread

[Web Push] How to display web notifications (18)

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

[Web Push] How to display web notifications (19)

Tiago Resende

Rank: #607

Solution

Replying to you asen's comment on 11 Apr 2024 10:07:28

Yes.

8 days ago

Copy link to comment

[Web Push] How to display web notifications (20)

you asen

Rank: #4900

Replying to Tiago Resende's comment on 11 Apr 2024 10:14:43

thanks a lot, I will try then I will get you back

8 days ago

Copy link to comment

Log in to Answer

Log in to AnswerLog in to Follow

[Web Push] How to display web notifications (2024)
Top Articles
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 6461

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.