Drupal is a registered trademark of Dries Buytaert

pf_notifications

18 sites Security covered
View on drupal.org

About

Provides web push notifications for DANSE events. Implements Web Push library for PHP, DANSE and Push framework, tailored and tested - a single case scenario though - to work with PWA.

Many thanks to:

For requirements see composer.json

Install and configure

  1. Get module via composer, this will fetch all requirements.
  2. Enable module drush en pf_notifications

  3. Add this permission to Role(s) who are granted to subscribe to notifications:
    Access POST on Push notification subscription resource
  4. Go to Configuration > System > Push framework > Notifications (/admin/config/system/push_framework/pf_notifications) and generate or enter VAPID keys. Tweak any other settings there.
  5. Try there Test notification too - check "Subscribe" checkbox there before hitting "Send" button.
  6. If not yet - configure DANSE content for Content and Comment types you wish to implement notifications. Check some resources @sebastix.nl and perhaps this issue.

There is an article written by @Sebastix here: https://sebastix.nl/blog/using-web-push-notifications-with-a-drupal-progressive-web-app/ explaining how to configure this module with DANSE and enable push notifications with the PWA module.

Usage scenario: a very basic example

  1. First test on config page, test notification found there.
  2. Login as user1 and post a content that will hold the thread with comments. Then, use DANSE's widget to subscribe for when other users comment there.
  3. In the other browser login as user2 and post a comment on the same content. Subscribe this user for any of available DANSE subscriptions.
  4. Then, either have advanced queue do its thing on cron runs, or if you have Ultimate cron module you can execute at least two jobs on the page /admin/config/system/cron/jobs. Or run DANSE notifications and PF queues with drush

    drush danse:notifications:create
    drush pf:sources:collect
    drush pf:queue:process

Result: user1 shall get the browser's/device's notification where is logged.

Other usage: direct notifications

To use direct notifications, skipping DANSE and Push framework, it's possible with a module's service. In particular with usage of 2 methods \Drupal::service('pf_notifications.subscription')->prepareLibraries($danse_key, 0, $entity) and
\Drupal::service('pf_notifications.subscription')->subscriptionResponse($op, $danse_key, $entity, $response, 0, FALSE).
See README for a full example.

Hooks

See pf_notifications.api.php for a couple of hooks available.

TODO

  • Implement Service worker unregister/update on uninstall. If module is installed again soon user may need to un-subscribe first, to flush existing, now invalid service worker subscription.
  • Push notification shall link to DANSE message, to flag it as seen?

Activity

Total releases
1
First release
Oct 2025
Latest release
4 months ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.0.1-beta2 Pre-release Oct 20, 2025