Data source: Pushover


1Presentation

Pushover offers a mobile application for sending push notifications without the need to develop a specific application.

If you have correctly configured the Pushover connection parameters, Temma automatically creates an object of type \Temma\Datasources\Pushover, with which you can send push notifications. By convention, we'll assume that you've named this connection push in the etc/temma.php file (see configuration documentation).

In the controllers, the Pushover connection is then available by writing:

$this->push

In other objects managed by the dependency injection component, the Pushover connection is accessible by writing:

$this->_loader->dataSources['push']

2Configuration

In the etc/temma.php file (see configuration documentation), you declare the DSN (Data Source Name) used to connect to Pushover.

The Pushover connection DSN is written as: pushover://APP_TOKEN
APP_TOKEN is supplied when an "application" is created in the user space.


3Unified calls

3.1Array-like access

// send notification
$this->push['USER_KEY'] = "Message to send";

3.2Raw data management

// send notification
$this->push->write('USER_KEY', "Message");

// send notifications with additional parameters
$this->push->write('USER_KEY', "Message", [
    'title'     => 'Message title',
    'html'      => false,
    'monospace' => true,
    'device'    => 'DEVICE_ID',
    'image'     => file_get_contents('picture.jpg'),
    'mimetype'  => 'image/jpeg',
    'priority'  => -1,
    'ttl'       =>  86400,
    'url'       => 'https://www.temma.net/',
    'urlTitle'  => 'Temma website',
]);

The optional parameters of the write() method are:

  • title: Title of the notification.
  • html: By default, messages can contain basic HTML tags. Set this parameter to false to prevent HTML interpretation.
  • monospace: Set this parameter to true to display the message with a monospace font. This disables HTML interpretation.
  • device: Allows the notification to be sent to a single user device, rather than to all devices (which is the default behavior).
  • image: Binary content of the image to accompany the notification. Also requires the mimetype parameter.
  • mimetype: MIME type of the image supplied in the image parameter.
  • priority: Notification priority.
    • -2: No notification. The message can be viewed in the application.
    • -1: No sound or vibration. Notification appears on screen.
    • 0: Default value. Sound, vibration and alert message.
    • 1: Notification even during the user's quiet hours.
    • 2: Notification repeats until acknowledged by user.
  • ttl: Number of seconds after which the message will disappear.
  • url: URL displayed below the message.
  • urlTitle: URL title. If not defined, the URL is displayed as is.

3.3HTML syntax

By default, the following HTML tags are interpreted in messages:

  • <b>: Text in bold.
  • <i>: Text in italic.
  • <u>: Underlined text.
  • <font color="#rrvvbb">: Colored text.
  • <a href="lien">: Hypertext link.