symfony/novu-notifier

Provides Novu integration for Symfony Notifier.

Installs: 240

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 4

Forks: 0

Type:symfony-notifier-bridge

v7.0.3 2024-01-23 15:02 UTC

This package is auto-updated.

Last update: 2024-04-18 09:34:32 UTC


README

Provides Novu integration for Symfony Notifier.

DSN example

NOVU_DSN=novu://API_KEY@default

Notification example

class NovuNotification extends Notification implements PushNotificationInterface
{
    public function asPushMessage(
        NovuSubscriberRecipient|RecipientInterface $recipient,
        ?string $transport = null,
    ): ?PushMessage {
        return new PushMessage(
            $this->getSubject(),
            $this->getContent(),
            new NovuOptions(
                $recipient->getSubscriberId(),
                $recipient->getFirstName(),
                $recipient->getLastName(),
                $recipient->getEmail(),
                $recipient->getPhone(),
                $recipient->getAvatar(),
                $recipient->getLocale(),
                $recipient->getOverrides(),
                [],
            ),
        );
    }
}
$notification = new NovuNotification;
$notification->subject('test');
$notification->channels(['push']);
$notification->content(
    json_encode(
        [
            'param1' => 'Lorum Ipsum',
        ]
    )
);

$this->notifier->send(
    $notification,
    new NovuSubscriberRecipient(
        "123",
        'Wouter',
        'van der Loop',
        'woutervdl@toppy.nl',
        null,
        null,
        null,
        [
            'email' => [
                'from' => 'no-reply@toppy.nl',
                'senderName' => 'No-Reply',
            ],
        ],
    ),
);

Resources