Download the PHP package dmytrof/push-notification-bundle without Composer
On this page you can find all versions of the php package dmytrof/push-notification-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download dmytrof/push-notification-bundle
More information about dmytrof/push-notification-bundle
Files in dmytrof/push-notification-bundle
Download dmytrof/push-notification-bundle
More information about dmytrof/push-notification-bundle
Files in dmytrof/push-notification-bundle
Vendor dmytrof
Package push-notification-bundle
Short Description Symfony2 bundle for sending push notifications with OneSignal
License MIT
Package push-notification-bundle
Short Description Symfony2 bundle for sending push notifications with OneSignal
License MIT
Please rate this library. Is it a good library?
Informations about the package push-notification-bundle
PushNotificationBundle
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 %}
All versions of push-notification-bundle with dependencies
PHP Build Version
Package Version
Requires
php Version
>=5.6
twig/twig Version 1.*
symfony/framework-bundle Version ^2.8
php-http/guzzle6-adapter Version ^1.1
norkunas/onesignal-php-api Version 1.0.x-dev
twig/twig Version 1.*
symfony/framework-bundle Version ^2.8
php-http/guzzle6-adapter Version ^1.1
norkunas/onesignal-php-api Version 1.0.x-dev
The package dmytrof/push-notification-bundle contains the following files
Loading the files please wait ....