matthewkilpatrick/symfony-pusher-notifier

Symfony Pusher Beams Notifier Bridge

dev-main 2021-07-14 18:48 UTC

This package is auto-updated.

Last update: 2024-04-15 01:26:03 UTC


README

This package adds support to Symfony Notifier for sending push notifications via the Pusher Beam API to iOS (APNS) devices, Android (FCM) devices, and browsers.

Installation

Install this package using Composer:

composer req matthewkilpatrick/symfony-pusher-notifier

And to register the factory, add the following to services section of the config/services.yaml config file:

notifier.transport_factory.pusher:
    class: Symfony\Component\Notifier\Bridge\Pusher\PusherTransportFactory
    parent: 'notifier.transport_factory.abstract'
    tags: [ 'chatter.transport_factory' ]

And ensure the following is present in config/packages/notifier.yaml:

framework:
    notifier:
        chatter_transports:
            pusher: '%env(PUSHER_DSN)%'

The DSN uses the following syntax:

pusher://YOUR_INSTANCE_ID:YOUR_SECRET_KEY@default

With the YOUR_INSTANCE_ID and YOUR_SECRET_KEY variables being values you can retrieve from the dashboard of your Pusher account.

Make this the DSN above (with your credentials) available as an env variable (PUSHER_DSN=pusher://...).

Usage

When passing data to the Pusher Notifier, setting a value for options is required. At minimum, you need to specify the user(s) or interest(s) which you want the message to be sent to.

You are also able to specify which channels to send messages to (by setting at least one of web, apns and fcm), though if none are provided, the notifier will default to sending the message subject to all configured channels.