Skip to content

[Notifier] Add Push Channel with Integration Expo & OneSignal #16077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions notifier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Get the Notifier installed using:

$ composer require symfony/notifier

Channels: Chatters, Texters, Email and Browser
----------------------------------------------
Channels: Chatters, Texters, Email, Browser and Push
----------------------------------------------------

The notifier component can send notifications to different channels. Each
channel can integrate with different providers (e.g. Slack or Twilio SMS)
Expand All @@ -36,6 +36,7 @@ The notifier component supports the following channels:
services like Slack and Telegram;
* :ref:`Email channel <notifier-email-channel>` integrates the :doc:`Symfony Mailer </mailer>`;
* Browser channel uses :ref:`flash messages <flash-messages>`.
* Push Channel sends notifications to phones via push notifications.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say not necessary to phones as it's possible to subscribe push notifications also via browser..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also thanks for writing docs for this :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 263bdd7 Thanks!


.. tip::

Expand Down Expand Up @@ -317,6 +318,75 @@ notification emails:
;
};

Push Channel
~~~~~~~~~~~~

The push channel is used to send notifications to users by using
:class:`Symfony\\Component\\Notifier\\Texter` classes. Symfony provides
integration with these push services:

============== ==================================== =================================================================================
Service Package DSN
============== ==================================== =================================================================================
Firebase ``symfony/firebase-notifier`` ``firebase://USERNAME:PASSWORD@default``
Expo ``symfony/expo-notifier`` ``expo://Token@default``
OneSignal ``symfony/one-signal-notifier`` ``onesignal://APP_ID:API_KEY@default?defaultRecipientId=DEFAULT_RECIPIENT_ID''``
============== ==================================== =================================================================================

.. versionadded:: 5.4

The Expo and OneSignal integrations were introduced in Symfony 5.4.

To enable a texter, add the correct DSN in your ``.env`` file and
configure the ``texter_transports``:

.. code-block:: bash

# .env
EXPO_DSN=expo://TOKEN@default

.. configuration-block::

.. code-block:: yaml

# config/packages/notifier.yaml
framework:
notifier:
texter_transports:
expo: '%env(EXPO_DSN)%'

.. code-block:: xml

<!-- config/packages/notifier.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:notifier>
<framework:texter-transport name="expo">
%env(EXPO_DSN)%
</framework:texter-transport>
</framework:notifier>
</framework:config>
</container>

.. code-block:: php

// config/packages/notifier.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
$framework->notifier()
->texterTransport('expo', '%env(EXPO_DSN)%')
;
};

Configure to use Failover or Round-Robin Transports
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down