wrep/notificato-symfony

负责处理您的Symfony2 & Symfony3项目的推送通知。

安装数: 4,464

依赖者: 0

建议者: 1

安全: 0

星标: 7

关注者: 3

分支: 4

开放问题: 0

类型:symfony-bundle

1.0.3 2017-11-14 06:32 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:03:44 UTC


README

Notificato负责处理您的Symfony2 & Symfony3项目的推送通知。

意大利语: notificato 是:过去分词 英语: notified

什么是Notificato?

Notificato让您能够从PHP项目中发送推送消息,这个存储库是一个用于简化集成到Symfony的Symfony2 & Symfony3组件。想了解更多关于Notificato的信息?请查看Notificato存储库

安装

1. 添加Composer依赖项

建议使用Composer安装。运行require命令将Notificato添加到您的项目中

composer require wrep/notificato-symfony

2. 在Kernel中包含组件

NotificatoBundle添加到app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        ...
        new Wrep\Bundle\NotificatoBundle\NotificatoBundle(),
        ...
    );
}

3. 配置默认证书

将以下配置选项添加到您的app/config.yml

notificato:
    apns:
        certificate:
            pem: /path/to/pem/certificate.pem       # Required if you want to use a default certificate
            passphrase: the-passphrase-of-the-pem   # Required if you want to use a default certificate
            validate: true                          # Optional, default true, set to false if certificate validation fails
            environment: sandbox                    # Optional, autodetect by default, set to production/sandbox if certificate validation fails

给定的证书将被用作默认证书。设置默认证书是完全可选的,但如果您只推送到一个应用,则建议这样做。

入门指南

安装完成后,您可以从任何ContainerAware环境中轻松地开始使用Notificato。假设您想从控制器发送推送消息

class PushController extends Controller
{
    public function indexAction()
    {
        // First we get a Notificato instance
        $notificato = $this->get('notificato');

        // Now let us get a fresh message from Notificato
        //  This message will be send to device with pushtoken 'fffff...'
        //  it will automaticly be associated with the default certificate
        $message = $notificato->createMessage('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');

        // Let's set App icon badge with this push to 1
        $message->setBadge(1);

        // The message is ready, let's send it!
        //  Be aware that this method is blocking and on failure Notificato will retry a few times
        $messageEnvelope = $notificato->send($message);

        // The returned envelope contains usefull information about how many retries where needed and if sending succeeded
        echo $messageEnvelope->getFinalStatusDescription();

        // Of course you should return a nice Response here!
    }
}

使用$this->get('notificato');获取一个已使用配置中的默认证书设置的Notificato对象。从那里开始,一切都与使用正常的Notificato库一样,所以请查看文档API描述以获取更多技巧和技巧。

请注意,还有更多服务可用于深入了解Notificato结构,如果您感兴趣,请查看services.xml。

贡献

我们非常欢迎贡献,请阅读Notificato的Contribute.md,以获取更多有关您可以做什么以及如果您想帮助,应该了解哪些内容的信息!

请注意,特定于Notificato的Symfony2 & Symfony3的问题和功能请求在GitHub问题跟踪器中跟踪,与这个存储库一起。对于Noticare本身的特定问题,可以在该存储库的问题跟踪器中提交。

许可证 & 致谢

Notificato for Symfony2 & Symfony3是在MIT许可证下由Rick PastoorMathijs Kadijk发布的,因此您可以在商业和非商业项目中自由使用它。