Adonis Notifications
A provider for easy sending notifications (Inspired Laravel Notifications)
Installation
- Add package:
$ npm i adonis-notifications --save
or
$ yarn add adonis-notifications
- Register providers inside the your start/app.js file.
const providers = ... 'adonis-notifications/providers/NotificationsProvider' ...
const aceProviders = ... 'adonis-notifications/providers/CommandsProvider' ...
- Notifications table
./ace run notifications:setup
Examples
// app/Model/User.js ... static { return '@provider:Morphable' '@provider:HasDatabaseNotifications' '@provider:Notifiable' }...
This package used adonis-lucid-polymorphic for database
channel.
// app/Notifications/TestNotification.js ... static { return 'test' } { return 'database' } { return foo: 'bar' }...
// app/Http/routes.js const Notifications = ... // from model instance const user = await User await user // to one user const user = await User await Notifications // to many users const users = await User await Notifications ...
Custom Channels
// app/providers/YourProvider.js ... { const NotificationManager = thisapp NotificationManager} ...
On-Demand Notifications
const FcmMessage = const Notifications = { thisanimal = animal } static { return 'pushtest' } { return 'fcm' } { const message = return message } Notifications
Channels
- adonis-fcm-notification-channel
- adonis-mail-notification-channel
- adonis-webhook-notification-channel
Credits
Support
Having trouble? Open an issue!
License
The MIT License (MIT). Please see License File for more information.