From 3fc3c5f39a586e04caf46fbb31fb691783a55db1 Mon Sep 17 00:00:00 2001 From: Zairig Imad Date: Sun, 7 Nov 2021 15:55:23 +0100 Subject: [PATCH] Add Push Channel with Integration Expo & OneSignal --- notifier.rst | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/notifier.rst b/notifier.rst index 8a56a0dc6ed..9a8d306ddca 100644 --- a/notifier.rst +++ b/notifier.rst @@ -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) @@ -36,6 +36,7 @@ The notifier component supports the following channels: services like Slack and Telegram; * :ref:`Email channel ` integrates the :doc:`Symfony Mailer `; * Browser channel uses :ref:`flash messages `. +* Push Channel sends notifications to phones via push notifications. .. tip:: @@ -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 + + + + + + + + + %env(EXPO_DSN)% + + + + + + .. 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~