dmytrof/push-notification-bundle
Composer 安装命令:
composer require dmytrof/push-notification-bundle
包简介
Symfony2 bundle for sending push notifications with OneSignal
README 文档
README
Symfony2 bundle for sending push notifications with OneSignal
Installation
Step 1: Composer require
$ php composer.phar require "norkunas/onesignal-php-api":"1.0.x-dev" "dmytrof/push-notification-bundle"
Step2: Enable the bundle in the kernel
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Dmytrof\PushNotificationBundle\DmytrofPushNotificationBundle(),
// ...
);
}
Configuration
Enable the bundle in your config.yml:
# app/config/config.yml
dmytrof_push_notification:
provider: one_signal
one_signal: # See: https://documentation.onesignal.com/docs/web-push-sdk-setup-http
app_id: "%one_signal.app_id%"
app_auth_key: "%one_signal.auth_key%"
safari_web_id: "%one_signal.safari_web_id%" # Safari Support (Optional). See: https://documentation.onesignal.com/docs/web-push-sdk-setup-http#section-3-safari-support-optional-
subdomain: "%one_signal.subdomain%" # HTTP Setup ONLY. See https://documentation.onesignal.com/docs/web-push-sdk-setup-http#section-1-4-choose-subdomain
Usage
Web Push SDK Setup
{# layout.html.twig #}
<head>
{# ... #}
{{ dmytrof_push_notification_web_sdk() }}
</head>
Tag your users
<?php
// SomeController
public function addTagAction()
{
// ...
$this->get('dmytrof_push_notification.provider')->addTag('tagName', 'tagValue');
// ...
}
public function addTagsAction()
{
// ...
$this->get('dmytrof_push_notification.provider')->addTags([
'tagName1' => 'value1',
'tagName2' => 'value2'
]);
// ...
}
Users will be tagged after rendering of layout with Web Push SDK
Remove tags
<?php
// SomeController
public function removeTagsAction()
{
// ...
$this->get('dmytrof_push_notification.provider')->removeTags([
'tagName1',
'tagName2'
]);
// ...
}
Tags will be removed after rendering of layout with Web Push SDK
Send Push Notification
<?php
// SomeController
public function sendNotificationAction()
{
// Send to all
$provider = $this->get('dmytrof_push_notification.provider');
$notification = $provider->createNotification()
->setSubject('Notification Subject')
->setMessage('Test notification for all')
->includeSegments(['All']);
$provider->sendNotification($notification);
// Filter by tags
$notification = $provider->createNotification()
->setSubject('Notification Subject')
->setMessage('Filtered by tags')
->filterByTag('tagName1', '=', 'value1')
->filterByTag('tagName2', '=', 'value2', true);
$provider->sendNotification($notification);
// Send templated message to user
$notification = $provider->createNotification()
->setTemplate('AppBundle:PushNotification:test_notification.html.twig', [
'user' => $user
])
->filterByTag('userId', '=', $user->getId());
$provider->sendNotification($notification);
}
Configure message template:
{# 'AppBundle:PushNotification:test_notification.html.twig' #}
{% extends 'DmytrofPushNotificationBundle:PushNotification:layout.html.twig' %}
{% block Subject %}
Test templated subject
{% endblock %}
{% block Message %}
Your user ID: {{ user.id }}
{% endblock %}
{% block Url %}
{{ absolute_url(path('YOUR_ROUTE')) }}
{% endblock %}
dmytrof/push-notification-bundle 适用场景与选型建议
dmytrof/push-notification-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 209 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 12 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dmytrof/push-notification-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dmytrof/push-notification-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 209
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-29