https://github.com/lekoala/silverstripe-pwa
PWA support in SilverStripe
https://github.com/lekoala/silverstripe-pwa
module push push-notifications pwa silverstripe
Last synced: 3 months ago
JSON representation
PWA support in SilverStripe
- Host: GitHub
- URL: https://github.com/lekoala/silverstripe-pwa
- Owner: lekoala
- License: mit
- Created: 2022-11-25T16:29:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-28T14:07:00.000Z (4 months ago)
- Last Synced: 2025-03-28T15:22:44.838Z (4 months ago)
- Topics: module, push, push-notifications, pwa, silverstripe
- Language: PHP
- Homepage:
- Size: 43.9 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# SilverStripe Pwa module

[](https://scrutinizer-ci.com/g/lekoala/silverstripe-pwa/)
[](https://codecov.io/gh/lekoala/silverstripe-pwa)## Features
- Support push notifications
- Generate a valid manifest
- Provides a default configurable service worker that can cache assets## Generate icons
Use the cli `npm run generate-assets(-root)` (if you have a `app/images/logo.svg` file) or upload a zip file with the required icons
Note: pay attention to [maskable icons](https://web.dev/maskable-icon/). You can test their
size in the developer console. You can test them in [maskable.app](https://maskable.app/)## Subscribe to push notifications
client.js provides some base code for this. You need to put somewhere a checkbox that can be used
to toggle push notifications on/off.```html
Enable notifications
```This is dealt with by client.js. You can replace client code by your custom code or disable it entirely
```yml
LeKoala\SsPwa\ServiceWorkerController:
enable_client_js: false
custom_client_path: "/my/custom/path"
```## Service worker
This module provides a default service worker. You can use your own if needed
```yml
LeKoala\SsPwa\ServiceWorkerController:
custom_sw_path: "/my/custom/path"
```## Use vapid keys
You can generate the vapid keys with this [online tool](https://tools.reactpwa.com/vapid) or with the cli `npm run gen-push-keys`
You need to save them either in your .env file or as YML config.
```
PUSH_PUBLIC_KEY='BK1Zt63e94HgYNm-s9aquI85AUdDRz3uKMxue7woQVZv0_3txywXPgyYd2WPJetayKYq3E_AObBGD9rHWOL_...'
PUSH_PRIVATE_KEY='1nKKQnzGRMNit-TuvklqoTY_ENO8eAybp1MsZWx0...'
```## Sending push notifications
You can use the following piece of code
```php
PushSubscription::sendPushNotifications($where, $data);
```## Credits
Thanks to https://github.com/a2nt/silverstripe-progressivewebapp for some inspiration :-)
## Compatibility
Tested with ^5
## Maintainer
LeKoala - [email protected]