Adds PWA functionality to a contao application.
This package is auto-updated.
Last update: 2023-11-19 08:15:06 UTC
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.
- 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)
composer require con4gis/pwa
Alternatively, you can use the Contao Manager to install the con4gis-PwaBundle.
- 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
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
There are three different ways to send push notifications with this bundle:
- Console Command (
- 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);
Visit docs.con4gis.org for a user documentation. You can also contact us via the support forum there.