minishlink / web-push-bundle

基于 WebPush 库的 Symfony 扩展包

安装数: 227,665

依赖者: 2

推荐者: 0

安全性: 0

星标: 45

关注者: 3

分支: 10

开放问题: 3

类型:symfony-bundle

v6.1.0 2024-05-04 10:24 UTC

This package is auto-updated.

Last update: 2024-09-04 11:12:15 UTC


README

本扩展包提供了对 WebPush 库 的简单集成。

SensioLabsInsight

用法

Web Push 通过端点发送通知,这些端点服务器按照 Web Push API 规范 描述的方式提供 Web Push 通知。

<?php
/** @var \Minishlink\WebPush\WebPush */
$webPush = $this->container->get('minishlink_web_push');

该扩展包提供了一个新的 minishlink_web_push 服务,它返回一个 Minishlink\WebPush\WebPush 的实例。

有关如何使用 $webPush 的更多信息,请查看 Minishlink/web-push

安装

  1. composer require minishlink/web-push-bundle
  2. 在您的 app/AppKernel.php 中启用扩展包。
<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Minishlink\Bundle\WebPushBundle\MinishlinkWebPushBundle(),
        // ...
    );
}

配置

以下是默认配置,您可以在您的 app/config/config.yml 中修改它。

minishlink_web_push:
  VAPID:
    subject: https://yoursite.com # can be an URL or a mailto:
    publicKey: ~88 chars          # uncompressed public key P-256 encoded in Base64-URL
    privateKey: ~44 chars         # the secret multiplier of the private key encoded in Base64-URL
    pemFile: path/to/pem          # if you have a PEM file and can link to it on your filesystem
    pem: pemFileContent           # if you have a PEM file and want to hardcode its content
  ttl: 2419200                    # Time to Live of notifications in seconds
  urgency: ~                      # can be very-low / low / normal / high
  topic: ~                        # default identifier for your notifications
  timeout: 30                     # Timeout of each request in seconds
  automatic_padding: true         # pad messages automatically for better security (against more bandwith usage)