Core Boxx – Push Notifications Module

TABLE OF CONTENTS

 

DOWNLOAD & INSTALLATION

First, the download links for the module, and also “installation instructions”.

 

LICENSE & DOWNLOAD

Core Boxx is released under the MIT License. You are free to use it for personal and commercial projects, and modify it as you see fit. On the condition that the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.

Download Core Boxx Push Notification Module | GitHubSource Forge

 

INSTALLATION

  • Install the “main” Core Boxx first, then unzip this module into your existing Core Boxx project folder.
  • Import lib/SQL-WebPush.sql into your database.
  • Access http://yoursite.com/push/1 to generate the private/public keys. Copy them into the PUSH NOTIFICATION KEYS section of lib/CORE-Config.php.
  • Access http://yoursite.com/push/2 and allow notifications to show.
  • Access http://yoursite.com/push/3 and send a test notification.

 

 

EXTRA NOTES

  • https:// is required for push notifications to work properly, http://localhost/ is an exception for testing.
  • Make sure that the OpenSSL extension is installed and enabled in PHP.
  • Windows users, if you are still getting an “unable to generate key” error:
    • Start > Search for “system environment” > “Edit the system environment variables” > “Environment variables”.
    • Add a new system variable called OPENSSL_CONF and point it to the openssl.cnf file. By default, it is located at xampp\php\extras\openssl\openssl.cnf.

 

FILES LIST

LIBRARIES

API

  • lib/API-Push.php Web Push API.

ASSETS & PAGES

  • pages/PAGE-push-1.php Step 1 – Generate VAPID keys.
  • pages/PAGE-push-2.php Step 2 – Register service worker and get permission.
  • pages/PAGE-push-3.php Step 3 – Send test push notification.
  • assets/PAGE-push.js Web Push Javascript.
  • assets/CORE-BOXX-PUSH-A.webp Push notification icon image. Change to your own if you want.
  • assets/CORE-BOXX-PUSH-B.webp Push notification cover image. Change to your own if you want.

 

DATABASE REFERENCE

There is only one table to store the “subscribed web push endpoints”. Feel free to add more fields as required – Maybe tie this to the users table.

 

WEB PUSH SUBSCRIBERS TABLE

Field Description
endpoint Primary key.
data JSON encoded subscriber object.

 

 

LIBRARY REFERENCE

Lastly, the list of library functions and API endpoints.

 

WEB PUSH LIBRARY FUNCTIONS

save($endpoint, $sub)

Save a subscriber.

  • $endpoint String, endpoint URL.
  • $sub String, JSON encoded subscriber object.
del($id)

Delete subscriber.

  • $endpoint String, endpoint URL.
send($title, $body, $icon, $image)

Send a push notification to all subscribers.

  • $title String, title of message.
  • $body String, text.
  • $icon String, URL of icon.
  • $image String, URL of background image.

 

WEB PUSH API FUNCTIONS

api/push/save/

Save subscriber.

  • $_POST["endpoint"] String, endpoint URL.
  • $_POST["sub"] String, JSON encoded subscriber object.
api/push/del/

Delete a subscriber.

  • $_POST["endpoint"] String, endpoint URL.
api/push/send/

Send a push notification.

  • $_POST["title"] String, title of message.
  • $_POST["body"] String, text.
  • $_POST["icon"] String, URL of icon.
  • $_POST["image"] String, URL of background image.

 

2 thoughts on “Core Boxx – Push Notifications Module”

  1. hello there
    am new to all of this so peer with me
    where should i find the PUBLIC-KEY & SECRET-KEY
    or should i generate it by my self.
    and how ?

    1. As “Installation” above – Access http://site.com/push/1 to generate the keys, copy them into lib/CORE-Config.php.

Leave a Comment

Your email address will not be published. Required fields are marked *