0

I'm looking for a way to push notification to desktop and mobile from a website built with D8. All modules I could find are abandoned sandbox or for D7... If I well understood, the way to push notification to desktop are different from the one to mobile.

Any help?

0

If you're looking for a ready-to-use solution, I don't think you're going to have much luck at this moment in time.

If you're willing to get your hands dirty and write some code, I would suggest looking at Pushbullet and its API. It's very easy to get started with and it can send push notifications to smartphones, web browsers and desktops (as long as they're running the requisite app or extension).

You could incorporate something as simple as this into a custom module:

$title = 'Some title text';
$body = 'Some body text';

$client = \Drupal::httpClient();
$request = $client->post('https://api.pushbullet.com/v2/pushes', array(
  'headers' => array(
    'Access-Token' => 'your_access_token_here',
  ),
  'json' => array(
    'type' => 'note',
    'title' => $title,
    'body' => $body,
  ),
));

You're not limited to simple text notifications either; it can push links and files as well.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.