apns-php
|
The Push Notification Message. More...
Public Member Functions | |
void | __construct (string $sDeviceToken=null) |
Constructor. More... | |
string | __toString () |
PHP Magic Method. More... | |
void | addRecipient (string $sDeviceToken) |
Add a recipient device token. More... | |
boolean | getAutoAdjustLongPayload () |
Get the auto-adjust long payload value. More... | |
integer | getBadge () |
Get the number to badge the application icon with. More... | |
string | getCategory () |
Get the category of notification. More... | |
boolean | getContentAvailable () |
Get if should initiates the Newsstand background download. More... | |
mixed | getCustomIdentifier () |
Get the custom message identifier. More... | |
string | getCustomProperty (string $sName) |
Get the custom property value. More... | |
string | getCustomPropertyName () |
Get the first custom property name. More... | |
array | getCustomPropertyNames () |
Get all custom properties names. More... | |
mixed | getCustomPropertyValue () |
Get the first custom property value. More... | |
integer | getExpiry () |
Get the expiry value. More... | |
string | getPayload () |
Convert the message in a JSON-encoded payload. More... | |
string | getRecipient (integer $nRecipient=0) |
Get a recipient. More... | |
array | getRecipients () |
Get all recipients. More... | |
integer | getRecipientsNumber () |
Get the number of recipients. More... | |
string | getSound () |
Get the sound to play. More... | |
string | getText () |
Get the alert message to display to the user. More... | |
void | setAutoAdjustLongPayload (boolean $bAutoAdjust) |
Set the auto-adjust long payload value. More... | |
void | setBadge (integer $nBadge) |
Set the number to badge the application icon with. More... | |
void | setCategory (string $sCategory= '') |
Set the category of notification. More... | |
void | setContentAvailable (boolean $bContentAvailable=true) |
Initiates the Newsstand background download. More... | |
void | setCustomIdentifier (mixed $mCustomIdentifier) |
Set the custom message identifier. More... | |
void | setCustomProperty (string $sName, mixed $mValue) |
Set a custom property. More... | |
void | setExpiry (integer $nExpiryValue) |
Set the expiry value. More... | |
void | setSound (string $sSound= 'default') |
Set the sound to play. More... | |
void | setText (string $sText) |
Set the alert message to display to the user. More... | |
Data Fields | |
const | APPLE_RESERVED_NAMESPACE = 'aps' |
string The Apple-reserved aps namespace. More... | |
const | PAYLOAD_MAXIMUM_SIZE = 2048 |
integer The maximum size allowed for a notification payload. More... | |
Protected Member Functions | |
array | _getPayload () |
Get the payload dictionary. More... | |
Protected Attributes | |
mixed | $_aCustomProperties |
Custom properties container. More... | |
array | $_aDeviceTokens = array() |
Recipients device tokens. More... | |
boolean | $_bAutoAdjustLongPayload = true |
If the JSON payload is longer than maximum allowed size, shorts message text. More... | |
boolean | $_bContentAvailable |
True to initiates the Newsstand background download. More... | |
mixed | $_mCustomIdentifier |
Custom message identifier. More... | |
integer | $_nBadge |
Number to badge the application icon with. More... | |
integer | $_nExpiryValue = 604800 |
That message will expire in 604800 seconds (86400 * 7, 7 days) if not successful delivered. More... | |
string | $_sCategory |
notification category. More... | |
string | $_sSound |
Sound to play. More... | |
string | $_sText |
Alert message to display to the user. More... | |
The Push Notification Message.
The class represents a message to be delivered to an end user device. Notification Service.
Definition at line 34 of file Message.php.
void __construct | ( | string | $sDeviceToken = null | ) |
Constructor.
$sDeviceToken | [optional] Recipients device token. |
Definition at line 60 of file Message.php.
References addRecipient().
string __toString | ( | ) |
PHP Magic Method.
When an object is "converted" to a string, JSON-encoded payload is returned.
Definition at line 346 of file Message.php.
References getPayload().
|
protected |
Get the payload dictionary.
Definition at line 361 of file Message.php.
Referenced by getPayload().
void addRecipient | ( | string | $sDeviceToken | ) |
Add a recipient device token.
$sDeviceToken | Recipients device token. |
ApnsPHP_Message_Exception | if the device token is not well formed. |
Definition at line 74 of file Message.php.
Referenced by __construct().
boolean getAutoAdjustLongPayload | ( | ) |
Get the auto-adjust long payload value.
Definition at line 335 of file Message.php.
References $_bAutoAdjustLongPayload.
integer getBadge | ( | ) |
Get the number to badge the application icon with.
Definition at line 164 of file Message.php.
References $_nBadge.
string getCategory | ( | ) |
Get the category of notification.
Definition at line 205 of file Message.php.
References $_sCategory.
boolean getContentAvailable | ( | ) |
Get if should initiates the Newsstand background download.
Definition at line 233 of file Message.php.
References $_bContentAvailable.
mixed getCustomIdentifier | ( | ) |
Get the custom message identifier.
Definition at line 485 of file Message.php.
References $_mCustomIdentifier.
string getCustomProperty | ( | string | $sName | ) |
Get the custom property value.
$sName | Custom property name. |
ApnsPHP_Message_Exception | if no property exists with the specified name. |
Definition at line 309 of file Message.php.
string getCustomPropertyName | ( | ) |
Get the first custom property name.
Definition at line 263 of file Message.php.
array getCustomPropertyNames | ( | ) |
Get all custom properties names.
Definition at line 293 of file Message.php.
mixed getCustomPropertyValue | ( | ) |
Get the first custom property value.
Definition at line 279 of file Message.php.
integer getExpiry | ( | ) |
Get the expiry value.
Definition at line 458 of file Message.php.
References $_nExpiryValue.
Referenced by ApnsPHP_Push::add().
string getPayload | ( | ) |
Convert the message in a JSON-encoded payload.
ApnsPHP_Message_Exception | if payload is longer than maximum allowed size and AutoAdjustLongPayload is disabled. |
Definition at line 397 of file Message.php.
References _getPayload().
Referenced by __toString(), and ApnsPHP_Push::add().
string getRecipient | ( | integer | $nRecipient = 0 | ) |
Get a recipient.
$nRecipient | [optional] Recipient number to return. |
ApnsPHP_Message_Exception | if no recipient number exists. |
Definition at line 92 of file Message.php.
Referenced by ApnsPHP_Push::add().
array getRecipients | ( | ) |
Get all recipients.
Definition at line 117 of file Message.php.
References $_aDeviceTokens.
integer getRecipientsNumber | ( | ) |
Get the number of recipients.
Definition at line 107 of file Message.php.
Referenced by ApnsPHP_Push::add().
string getSound | ( | ) |
Get the sound to play.
Definition at line 185 of file Message.php.
References $_sSound.
string getText | ( | ) |
Get the alert message to display to the user.
Definition at line 137 of file Message.php.
References $_sText.
void setAutoAdjustLongPayload | ( | boolean | $bAutoAdjust | ) |
Set the auto-adjust long payload value.
$bAutoAdjust | If true a long payload is shorted cutting long text value. |
Definition at line 325 of file Message.php.
void setBadge | ( | integer | $nBadge | ) |
Set the number to badge the application icon with.
$nBadge | A number to badge the application icon with. |
ApnsPHP_Message_Exception | if badge is not an integer. |
Definition at line 149 of file Message.php.
void setCategory | ( | string | $sCategory = '' | ) |
Set the category of notification.
$sCategory | [optional] A category for ios8 notification actions. |
Definition at line 195 of file Message.php.
void setContentAvailable | ( | boolean | $bContentAvailable = true | ) |
Initiates the Newsstand background download.
$bContentAvailable | True to initiates the Newsstand background download. |
ApnsPHP_Message_Exception | if ContentAvailable is not a boolean. |
Definition at line 218 of file Message.php.
void setCustomIdentifier | ( | mixed | $mCustomIdentifier | ) |
Set the custom message identifier.
The custom message identifier is useful to associate a push notification to a DB record or an User entry for example. The custom message identifier can be retrieved in case of error using the getCustomIdentifier() method of an entry retrieved by the getErrors() method. This custom identifier, if present, is also used in all status message by the ApnsPHP_Push class.
$mCustomIdentifier | The custom message identifier. |
Definition at line 475 of file Message.php.
void setCustomProperty | ( | string | $sName, |
mixed | $mValue | ||
) |
Set a custom property.
$sName | Custom property name. |
$mValue | Custom property value. |
ApnsPHP_Message_Exception | if custom property name is not outside the Apple-reserved 'aps' namespace. |
Definition at line 246 of file Message.php.
void setExpiry | ( | integer | $nExpiryValue | ) |
Set the expiry value.
$nExpiryValue | This message will expire in N seconds if not successful delivered. |
Definition at line 443 of file Message.php.
void setSound | ( | string | $sSound = 'default' | ) |
Set the sound to play.
$sSound | [optional] A sound to play ('default sound' is the default sound). |
Definition at line 175 of file Message.php.
void setText | ( | string | $sText | ) |
Set the alert message to display to the user.
$sText | An alert message to display to the user. |
Definition at line 127 of file Message.php.
|
protected |
Custom properties container.
Definition at line 49 of file Message.php.
|
protected |
|
protected |
If the JSON payload is longer than maximum allowed size, shorts message text.
Definition at line 39 of file Message.php.
Referenced by getAutoAdjustLongPayload().
|
protected |
True to initiates the Newsstand background download.
Definition at line 47 of file Message.php.
Referenced by getContentAvailable().
|
protected |
Custom message identifier.
Definition at line 53 of file Message.php.
Referenced by getCustomIdentifier().
|
protected |
Number to badge the application icon with.
Definition at line 44 of file Message.php.
Referenced by getBadge().
|
protected |
That message will expire in 604800 seconds (86400 * 7, 7 days) if not successful delivered.
Definition at line 51 of file Message.php.
Referenced by getExpiry().
|
protected |
|
protected |
|
protected |
Alert message to display to the user.
Definition at line 43 of file Message.php.
Referenced by getText().
const APPLE_RESERVED_NAMESPACE = 'aps' |
string The Apple-reserved aps namespace.
Definition at line 37 of file Message.php.
const PAYLOAD_MAXIMUM_SIZE = 2048 |
integer The maximum size allowed for a notification payload.
Definition at line 36 of file Message.php.