php-pushwoosh

A PHP Library to easily send push notifications with the Pushwoosh REST Web Services.

View project onGitHub
Search

/createMessage

Remote API Guide link
Method /createMessage

Signature
CreateMessageResponse createMessage(CreateMessageRequest $createMessageRequest)

CreateMessageRequest class

Full name
Gomoob\Pushwoosh\Model\Request\CreateMessageRequest

The CreateMessageRequest class is principally used to define a list of Notification objects where each object defines a Pushwoosh push notification to send to a set of devices.

You can manipulate the Notification objects linked to a CreateMessageRequest object by using the addNotification($notification), getNotifications() and setNotifications() methods.

<?php
use Gomoob\Pushwoosh\Model\Notification\Notification;
use Gomoob\Pushwoosh\Model\Request\CreateMessageRequest;

// Adding notifications using the 'addNotification($notification)' method
$request0 = CreateMessageRequest::create()
    ->addNotification(Notification::create()->setContent('Hello'))
    ->addNotification(Notification::create()->setContent('World'))
    ->addNotification(Notification::create()->setContent('!'));

// Adding notifications using the 'setNotifications($notifications)' method
$request1 = CreateMessageRequest::create()->setNotifications(
    array(
        Notification::create()->setContent('Hello'),
        Notification::create()->setContent('World'),
        Notification::create()->setContent('!'),
    )
); 

// Call the '/createMessage' Web Service
$pushwoosh->createMessage($request0);
$pushwoosh->createMessage($request1);

?>

Notification class

Full name
Gomoob\Pushwoosh\Model\Notification\Notification

The Notification class allow to describe the content of a Push Notification to be sent to one or multiple devices.

General settings


conditions
Methods
addCondition($condition), getConditions(), setConditions($conditions)
Sample

<?php
// Setting conditions with the 'addCondition' method
$notification = Notification::create()
    ->addCondition(StringCondition::create('stringCondition')->eq('toto'));
    ->addCondition(IntCondition::create('intCondition')->lte(15));
    ->addCondition(ListCondition::create('listCondition')->in(array('value 1', 'value 2', 'value 3')));

// Setting conditions with the 'setConditions' method
$notification = Notification::create()->setConditions(
    array(
        StringCondition::create('stringCondition')->eq('toto'),
        IntCondition::create('intCondition')->lte(15),
        ListCondition::create('listCondition')->in(array('value 1', 'value 2', 'value 3')));
    )
);
?>
	

content
Methods
getContent(), setContent($content)
Sample

<?php
// Setting the same content for all languages
$notification = Notification::create()->setContent('Hello World !');

// Setting different contents depending on the language
$notification = Notification::create()
    ->setContent(
        array(
            'fr' => 'Bonjour !',
            'en' => 'Hello !',
            'es' => 'Buenos Dias !'
        )
    );
?>
    

data
Methods
getData(), setData($data)
Sample

<?php
$notification = Notification::create()->setData(
    array(
        'data_parameter_1' => 'data_parameter_1_value',
        'data_parameter_2', 'data_parameter_2_value'
    )
);
?>
    

devices
Methods
addDevice($device), getDevices(), setDevices($devices)
Sample

<?php
// Setting devices with the 'addDevice' method
$notification = Notification::create()
    ->addDevice('Device 0')
    ->addDevice('Device 1')
    ->addDevice('Device 2');

// Setting devices with the 'setDevices' method
$notification = Notification::create()
    ->setDevices(
        array(
            'Device 0',
            'Device 1',
            'Device 2'
        )
    );
?>
    

filter
Methods
getFilter(), setFilter($filter)
Sample

<?php
$notification = Notification::create()->setFilter('FILTER_NAME');
?>
    

ignoreUserTimezone
Methods
isIgnoreUserTimezone(), setIgnoreUserTimezone($ignoreUserTimezone)
Sample

<?php
Notification::create()->setIgnoreUserTimezone(false);
?>
    

link
Methods
getLink(), setLink($link)
Sample

<?php
Notification::create()->setLink('http://www.gomoob.com');
?>
    

minimizeLink
Methods
getMinimizeLink(), setMinimizeLink($minimizeLink)
Sample

<?php
// No minimization
Notification::create()->setMinimizeLink(MinimizeLink::none());

// Google minimization
Notification::create()->setMinimizeLink(MinimizeLink::google());

// Bitly minimization
Notification::create()->setMinimizeLink(MinimizeLink::bitly());

// Baidu (china) minimization
Notification::create()->setMinimizeLink(MinimizeLink::baiduChina());
?>
    

pageId
Methods
getPageId(), setPageId($pageId)
Sample

<?php
Notification::create()->setPageId(39);
?>
    

platforms
Methods
addPlatform($platform), getPlatforms(), setPlatforms($platforms)
Sample

<?php
// Setting platforms with the 'addPlatform' function
Notification::create()
    ->addPlatform(Platform::ios())
    ->addPlatform(Platform::android())
    ->addPlatform(Platform::blackBerry());

// Setting platforms with the 'setPlatforms' function
Notification::create()->setPlatforms(
    array(
        Platform::ios(),
        Platform::android(),
        Platform::blackBerry()
    )
)
?>
    

preset
Methods
getPreset(), setPreset($preset)
Sample

<?php
Notification::create()->setPreset('Q1A2Z-6X8SW');
?>
    

remotePage
Methods
getRemotePage(), setRemotePage($remotePage)
Sample

<?php
Notification::create()->setRemotePage('http://myremoteurl.com');
?>
    

richPageId
Methods
getRichPageId(), setRichPageId($richPageId)
Sample

<?php
Notification::create()->setRichPageId(42);
?>
    

sendDate
Methods
getSendDate(), setSendDate($sendDate)
Sample

<?php
// Set a specific date
Notification::create()->setSendDate($dateTime);

// Or simply set 'now'
Notification::create()->setSendDate('now');
?>
    

sendRate
Methods
getSendRate(), setSendRate($sendRate)
Sample

<?php
Notification::create()->setSendRate(200);
?>
    

Specific platform settings

In addition to generic notification settings it's possible to specify specific settings depending on the platform where the Push notifications are sent.

Each specific platform setting is defined using an additional setting object, the classes used to create those settings objects are described in the following sections.

Amazon Device Messaging

Class name
Gomoob\Pushwoosh\Model\Notification\ADM

Sample

<?php
Notification::create()->setADM(
    ADM::create()->setBanner($banner)
                 ->setCustomIcon($customIcon)
                 ->setHeader($header)
                 ->setIcon($icon)
                 ->setRootParams($rootParams)
                 ->setSound($sound)
                 ->setTtl($ttl)
);
?>
    

Android

Class name
Gomoob\Pushwoosh\Model\Notification\Android

Sample

<?php
Notification::create()->setAndroid(
    Android::create()->setBadges($badges)
                 ->setBanner($banner)
                 ->setCustomIcon($customIcon)
                 ->setGcmTtl(3600)
                 ->setHeader($header)
                 ->setIbc($ibc)
                 ->setIcon($icon)
                 ->setLed($led)
                 ->setPriority($priority)
                 ->setRootParams($rootParams)
                 ->setSound($sound)
                 ->setVibration($vibration)
);
?>
    

BlackBerry

Class name
Gomoob\Pushwoosh\Model\Notification\BlackBerry

Sample

<?php
Notification::create()->setBackBerry(
    BlackBerry::create()->setHeader($header)
);
?>
    

Chrome

Class name
Gomoob\Pushwoosh\Model\Notification\Chrome

Sample

<?php
Notification::create()->setChrome(
    Chrome::create()->setGcmTtl($gcmTtl)
                ->setIcon($icon)
                ->setTitle($title)
);
?>
    

iOS

Class name
Gomoob\Pushwoosh\Model\Notification\IOS

Sample

<?php
Notification::create()->setIOS(
    IOS::create()->setAps($apsr)
                 ->setApnsTrimContent($apnsTrimContent)
                 ->setBadges($badges)
                 ->setContentAvailable($contentAvailable)
                 ->setRootParams($rootParams)
                 ->setSound($sound)
                 ->setTtl($ttl)
);
?>
    

Mac OS X

Class name
Gomoob\Pushwoosh\Model\Notification\Mac

Sample

<?php
Notification::create()->setMac(
    Mac::create()->setBadges($badges)
                 ->setRootParams($rootParams)
                 ->setSound($sound)
                 ->setTtl($ttl)
);
?>
    

Safari

Class name
Gomoob\Pushwoosh\Model\Notification\Safari

Sample

<?php
Notification::create()->setSafari(
    Safari::create()->setAction($action)
                    ->setTitle($title)
                    ->setTtl($ttl)
                    ->setUrl($url)
);
?>
    

Windows Notification Service

Class name
Gomoob\Pushwoosh\Model\Notification\WNS

Sample

<?php
Notification::create()->setWNS(
    WNS::create()->setContent($content)
                 ->setTag($tag)
                 ->setType($type)
);
?>
    

Windows Phone

Class name
Gomoob\Pushwoosh\Model\Notification\WP

Sample

<?php
Notification::create()->setWP(
    WP::create()->setBackbackground($backbackgroud)
                ->setBackground($background)
                ->setBacktitle($backtitle)
                ->setCount($count)
                ->setType($type)
);
?>
    

CreateMessageResponse class