How can you better implement the following?

a person clicks on the button "subscribe to updates" and, in fact, it is desirable that this is all over.

I thought about using browser notifications, but I still didn’t understand whether it could be implemented in such a way that a person would receive notifications only about those news to which he was subscribed.

I do not consider the option of sending e-mail.

  • By the way, if you suddenly try a bunch of services that are not listed in the answer - do not forget to share the list) - Alexey Shimansky

1 answer 1

I just finished the study and can share it.

The first thing to mention, if suddenly you did not know:

You cannot implement them "just by screwing some kind of library or plugin on js". It is solved now like this: large vendors of browsers provide their services through which you can accordingly work with the browsers of these vendors.

Taken from the notification topic in the browser (such as VC or another) . I also looked at a couple of services that can help (of course, not all services, but for example, enough):

  1. https://onesignal.com/
  2. https://clevertap.com/

Following the example of ONESIGNAL , the following happened:

You can assign any tag or group of tags to each user who has come to the site or by clicking in the settings to subscribe to specific sections (each tag will correspond to one distribution point on the site). This can be seen in the corresponding section of the service:

enter image description here

You can assign tags, watch the user ID, and set various settings for the user through the Web Push SDK .

From the image above you can see that the bottom user has tags:

{kino:true, delivery:true} 

That is, it is abstractly subscribed to cinema and delivery notifications. The other with {tort:true} abstractly subscribed to notifications about the cake section.

Now, using the REST API , which provides this service, you can send messages by filtering the data on various grounds. If specifically, then in this case we will focus on those tags that are the user.

The following code will send a message to users who subscribe to the kino and tort sections:

 function sendMessage($themes){ $content = array( "en" => 'Привет user тут уведомления для юзера, который подписан на '. implode(', ', $themes) .'!' ); $filters = []; foreach ($themes as $theme) { $themeItem = ["field" => "tag", "key" => $theme, "relation" => "=", "value" => true ]; array_push($filters, $themeItem); array_push($filters, ["operator" => "OR"]); } array_pop($filters); $fields = array( 'app_id' => "a6a6a6a6-6666-6666-6666-a6a6a6a6a6", 'filters' => $filters, 'data' => array("foo" => "bar"), 'contents' => $content ); $fields = json_encode($fields); print("\nJSON sent:\n"); print($fields); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8', 'Authorization: Basic SDfojisdofiOIDFJOISjfoisFOIJFDSfjoijOIFJSOIFJoisf')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $response = curl_exec($ch); curl_close($ch); return $response; } $themes = ['kino', 'tort']; $response = sendMessage($themes); 


Accordingly, you can send data to specific users at any time.

Everything.

For this service there is detailed documentation , supports the following:

enter image description here



Happy end! (???)

Homework:

The fact that the push notification services are many is a fact. But I can not say for sure what other services exist with similar functionality. You just have to explore the services of the mailing services yourself and poke into the settings and find something similar.