One Signal

Table of content

About

This class allows you to send One Signal notifications. It uses the Request class to perform HTTP requests.

Requirements

This requires lib curl to be active with your PHP settings. This also requires a token from One Signal services.

Available methods

Send notification

Send a push notification using the One Signal V1 API endpoint.

$oneSignal = new OneSignal("your-OneSignal-api-token");
$oneSignalAppId = "00000000-0000-0000-8000-000000000000";
$heading = "My push notification";
$content = "Hi!\n\nSome content of the notification";

$fields = array(
    'app_id' => $oneSignalAppId,
    'included_segments' => array('All'),
    'headings' => array('en' => $heading),
    'contents' => array('en' => $content),
    'web_push_topic' => 'unique-topic-identification',
    'chrome_web_icon' => 'https://example.com/images/logo.png'
);
$oneSignal->sendNotification($fields);