cmnty/push-bundle

该包已被废弃,不再维护。未建议替代包。

cmnty/push 的 Symfony Bundle

安装量: 13,399

依赖者: 0

建议者: 0

安全性: 0

星标: 1

关注者: 6

分支: 1

开放问题: 0

类型:symfony-bundle

0.0.2 2016-09-07 08:43 UTC

This package is not auto-updated.

Last update: 2022-04-30 06:22:12 UTC


README

Latest Version on Packagist Software License Total Downloads

Symfony Bundle for cmnty/push.

安装

使用 composer 安装该包

composer require cmnty/push-bundle

app/AppKernel.php 中注册该包

public function registerBundles()
{
    $bundles = [
        // ...
        new Cmnty\PushBundle\CmntyPushBundle(),
        // ...
    ];

    return $bundles;
}

配置

cmnty_push:
    push_services:
        google:
            enabled: true # Default false, automatically true when api_key is supplied.
            api_key: "%gcm_sender_id%" # Required value.
        mozilla:
            enabled: true # Default true

如果您计划使用 doctrine 存储推送订阅,可以使用该包提供的映射。

# Doctrine Configuration
doctrine:
    dbal:
        types:
            binary_string: Cmnty\PushBundle\Doctrine\Type\BinaryStringType
    orm:
        mappings:
            PushSubscription:
                type: xml
                prefix: Cmnty\Push
                dir: "%kernel.root_dir%/../vendor/cmnty/push-bundle/src/Resources/config/embeddable"
                is_bundle: false

使用方法

<?php

use Cmnty\Push\Crypto\AuthenticationSecret;
use Cmnty\Push\Crypto\PublicKey;
use Cmnty\Push\EndPoint;
use Cmnty\Push\Notification;
use Cmnty\Push\Subscription;

$notification = new Notification('Hello', 'Symfony!');
$subscription = new Subscription(
    new Endpoint('...'),
    new PublicKey::createFromBase64UrlEncodedString('...'),
    new AuthenticationSecret::createFromBase64UrlEncodedString('...')
);

$client = $this->get('cmnty_push.client');
$client->pushNotification($notification, $subscription);

致谢

许可证

MIT 许可证(MIT)。请参阅 许可证文件 获取更多信息。