PHP Classes

PHP Web Push Notifications Server: Queue and push notifications to Web users

Recommend this page to a friend!
  Info   View files Example   View files View files (21)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2020-05-05 (26 days ago) RSS 2.0 feedNot enough user ratingsTotal: 349 This week: 126All time: 6,883 This week: 2Up
Version License PHP version Categories
pnserver 1.0.0Freely Distributable7.1Web services, PHP 7
Description Author

This package can queue and push notifications to Web users.

It can register the interest of users to receive notifications from the server by creating user subscriptions.

The package provides means to queue notification messages to be sent to users of an application by storing them in a database.

Then it can return queued messages, so they can be shown to Web uses on a Web page using custom JavaScript code that pulls the messages from the server using this package.

The package can also automatically delete expired messages and no longer valid subscriptions.

Innovation Award
PHP Programming Innovation award nominee
April 2020
Nominee
Vote
Web based push notifications are useful to let users of a site know about anything new that happens on a site that may be of the interest of those users.

This package provides a complete solution to register users interested to subscribe to get notifications from a site, queue notifications to be pushed to the users when they come to the site, and even perform maintenance on the notifications and subscriptions created by the users.

Manuel Lemos
  Performance   Level  
Name: Stefan Kientzler is available for providing paid consulting. Contact Stefan Kientzler .
Classes: 10 packages by
Country: Germany Germany
Age: 52
All time rank: 2330147 in Germany Germany
Week rank: 1 Up
Innovation award
Innovation award
Nominee: 5x

Winner: 2x

Details

PNServer - Web Push Notifications for your Homepage

Latest Stable Version License Minimum PHP Version

With this package, web push notifications can be created, encrypted and sent via HTTP request. The subscriptions can be saved and managed. Optionally, the package automatically deletes expired or no longer valid subscriptions. The JavaScript code required on the client side is also included in the package - this has to be slightly adapted to your own project.

there are no dependencies to other external libraries!

PHP >= 7.1 is required to be able to generate the necessary encryption keys - The curve_name configarg was added to openssl_pkey_new() in this version to make it possible to create EC keys!

required PHP Libraries

  • cURL (curl)
  • Multibyte String (mbstring)
  • OpenSSL (openssl)
  • GNU Multiple Precision (gmp)
  • BC Math (bcmath)

Installation

You can download the Latest release version from PHPClasses.org

required adaptions for your own project (in PNServiceworker.js):

  // VAPID appPublic key
  const strAppPublicKey   = 'create your own VAPID key pair and insert public key here';
  // URL to save subscription on server via Fetch API
  const strSubscriberURL  = 'https://www.your-domain.org/PNSubscriber.php';
  // default Notification Title if not pushed by server
  const strDefTitle       = 'Your company or product';
  // default Notification Icon if not pushed by server
  const strDefIcon        = './elephpant.png';

you can generate your own VAPID key on https://tools.reactpwa.com/vapid.

Usage

A tutorial describing the individual steps for using the package is available at PHPclasses.org.

PnTestClient.html shows a simple Page to subscribe the push notifications.

PNTestServer.php demonstrates, how the Notification Server can be implemented: insert your own VAPID key at following lines:

  // set the VAPID key
  $oVapid = new PNVapid(
          "mailto:yourmail@yourdomain.de",
          "insert your own VAPID public-key here",
          "insert your own VAPID private-key here"
      );
  $oServer->setVapid($oVapid);

  Files folder image Files  
File Role Description
Files folder imagelib (1 directory)
Accessible without login Image file elephpant.png Icon Icon image
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file PNClient.js Data Auxiliary data
Accessible without login Plain text file PNServiceWorker.js Data Auxiliary data
Accessible without login Plain text file PNSubscriber.php Example Example script
Accessible without login Plain text file PNTestClient.html Data Example HTML page client
Accessible without login Plain text file PNTestServer.php Example Example script
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  lib  
File Role Description
Files folder imagePNServer (9 files, 1 directory)

  Files folder image Files  /  lib  /  PNServer  
File Role Description
Files folder imageUtils (4 files)
  Plain text file PNDataProvider.php Class Class source
  Plain text file PNDataProviderMySQL.php Class Class source
  Plain text file PNDataProviderSQLite.php Class Class source
  Plain text file PNEncryption.php Class Class source
  Plain text file PNPayload.php Class Class source
  Plain text file PNServer.php Class Class source
  Plain text file PNServerHelper.php Class Class source
  Plain text file PNSubscription.php Class Class source
  Plain text file PNVapid.php Class Class source

  Files folder image Files  /  lib  /  PNServer  /  Utils  
File Role Description
  Plain text file Curve.php Class Class source
  Plain text file Math.php Class Class source
  Plain text file NistCurve.php Class Class source
  Plain text file Point.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:349
This week:126
All time:6,883
This week:2Up

For more information send a message to info at phpclasses dot org.