Notification
is the main model of JoliNotif. It contains all the options
that should be applied - if possible - by the driver.
Note Drivers are designed to handle the options they support and discard not supported ones gracefully without throwing any exception.
Currently, only three options are supported but new ones could be added later.
Each option can be set via a setter on the Notification
class.
The body is the main message of the notification that you want to display.
Note This is the only required option. Drivers will throw an
InvalidNotificationException
if the body is empty or null.
You can also optionally provide a title. Drivers will certainly display the title above the body, in bold.
An icon can also be displayed inside the notification. You will need to set an absolute path.
$notification->setIcon(__DIR__.'/Resources/icons/success.png');
Note If you use JoliNotif from a phar and add a notification icon, we will take care to extract this icon in your system temp directory to make it accessible from command line executable.
Not all drivers support icon but again, you can safely add an icon to your notification since the driver will simply discard it if not supported.
Some options are available only on few drivers. They can be configured
through the addOption
method.
Only works with AppleScriptDriver at the moment.
$notification->addOption('subtitle', 'This is a subtitle');
Only works with AppleScriptDriver and TerminalNotifierDriver at the moment.
Non-exhaustive list of sounds: Basso, Frog, Hero, Pop, Submarine, Blow, Funk, Morse, Purr, Tink, Bottle, Glass, Ping, Sosumi.
$notification->addOption('sound', 'Frog');
Only works with TerminalNotifierDriver at the moment.
$notification->addOption('url', 'https://google.com');
Previous pages: