lekoala/silverstripe-pwa 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱: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"

Exclude from cache

If you want to exclude specific patterns (eg: pdf files) from cache, you can use:

LeKoala\SsPwa\ServiceWorkerController:
  exclude_from_cache:
    - '/\.pdf$/i'

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
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固