con4gis / pwa
Adds PWA functionality to a contao application.
Installs: 1 275
Dependents: 1
Suggesters: 0
Security: 0
Stars: 9
Watchers: 4
Forks: 1
Open Issues: 4
Type:contao-bundle
Requires
- php: ^7.4 || ^8.0
- con4gis/core: ^6.0 || ^7.0
- contao-components/jquery: ^3.6
- contao/core-bundle: ^4.9 || ^5.0
- doctrine/data-fixtures: ^1.4.4
- doctrine/orm: ^2.8.5
- doctrine/persistence: ^2.3.0
- minishlink/web-push-bundle: ^6
Conflicts
- contao/core: *
- contao/manager-plugin: <2.0 || >=3.0
- dev-main
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.1
- v2.1.0
- v2.1.0rc2
- v2.1.0rc1
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- dev-dependabot/npm_and_yarn/webpack-5.94.0
- dev-dependabot/npm_and_yarn/braces-3.0.3
- dev-feature_multidomain
This package is auto-updated.
Last update: 2024-10-31 00:18:33 UTC
README
Overview
Turn your Contao Website into a progressive web app. The con4gis-PwaBundle provides everything you need for basic PWA functionality, including generating a service worker script and a manifest file.
Features include:
- Configuration of required parameters for the webmanifest
- Select a pwa configuration in the page root. On submit the service worker and manifest for this page root will be generated for you.
- Multiple offline behaviours: choose whether you want to cache everything or if you always want to redirect to a chosen offline page.
- WebPushConfiguration: configure the web push library in the backend so your users can register for push notifications.
- Add icons for app splashscreens (Android & iOS)
Installation
Via composer:
composer require con4gis/pwa
Alternatively, you can use the Contao Manager to install the con4gis-PwaBundle.
Requirements
- Contao (latest stable release)
- CoreBundle (latest stable release)
- WebPushBundle (3.* (latest))
- The php-gmp extension is required by the used web-push-library and has to be installed/activated if the installation failes for this reason
Usage
This bundles provides two front end modules for contao:
PWA module (add manifest)
Creates the required HTML code to load the manifest file and the service worker. Can be included anywhere on the page since it contains no visible elements by itself.
Push subscription button
Creates the button to subscribe to push notifications as well as loading the javascript needed to handle the subscription. The button comes unstyled, but can be accessed via the "btn-push-subscribe"-ID for individual styling.
Sending a notification
There are three different ways to send push notifications with this bundle:
- Console Command (
con4gis:send-push <message>
) - Backend Module (Create a new dataset and store it - it won't be stored in the database but is sent to all subscribed users instead)
- Sending a notification programmatically
To send a notification in one of your scripts, you have to create a PushNotificationEvent and use the Symfony event dispatcher.
// get the event dispatcher $eventDispatcher = $this->eventDispatcher; // instantiate event $event = new PushNotificationEvent(); // this sends the notification to every subscribed user. You can send a notification to only one subscription, too $event->setSendToAll(true); // set message contents $event->setTitle($title); $event->setMessage($content); // dispatch the event $eventDispatcher->dispatch($event::NAME, $event);
Documentation
Visit docs.con4gis.org for a user documentation. You can also contact us via the support forum there.