定制 lekoala/silverstripe-pwa 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lekoala/silverstripe-pwa

Composer 安装命令:

composer require lekoala/silverstripe-pwa

包简介

Create your progressive web app (PWA) with SilverStripe

README 文档

README

Build Status scrutinizer Code coverage

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. You can test their size in the developer console. You can test them in 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.

<label><input type="checkbox" class="js-push-toggle" /> Enable notifications</label>

This is dealt with by client.js. You can replace client code by your custom code or disable it entirely

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

LeKoala\SsPwa\ServiceWorkerController:
  custom_sw_path: "/my/custom/path"

Use vapid keys

You can generate the vapid keys with this online tool 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

PushSubscription::sendPushNotifications($where, $data);

Credits

Thanks to https://github.com/a2nt/silverstripe-progressivewebapp for some inspiration :-)

Compatibility

Tested with ^5

Maintainer

LeKoala - thomas@lekoala.be

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-30