class MessageBuilder

Methods

setDeviceToken(string $deviceToken)

Set the receiver of the message

setCertificate(Certificate $certificate)

Set the certificate to use when

setExpiresAt(DateTime $expiresAt = null)

Set the moment this message should expire or null if APNS should not store the message at all.

setAlert(string|null $body, string|null $actionLocKey = null, string|null $launchImage = null)

Set the alert to display.

setAlertLocalized(string $locKey, array $locArgs = array(), string|null $actionLocKey = null, string|null $launchImage = null)

Set the localized alert to display.

addAlertAction(string $id, string $title)

Add custom (iOS 8+) actions to the alert you display Note: You must also call setAlert() or setAlertLocalized() to make a complete alert

addAlertActionLocalized($id, $locKey, $locArgs = array())

Add localized custom (iOS 8+) actions to the alert you display Note: You must also call setAlert() or setAlertLocalized() to make a complete alert

setBadge(int|null $badge)

Set the badge to display on the App icon

clearBadge()

Clear the badge from the App icon

setSound(string $sound = 'default')

Set the sound that will be played when this message is received

setContentAvailable(boolean $contentAvailable)

Set newsstand content availability flag that will trigger the newsstand item to download new content

setCategory(string $category)

Set the category identifier for this message used by the app to display custom actions

setPayload(array|json|null $payload)

Set custom payload to go with the message

build()

Build the message

Details

at line 27
MessageBuilder setDeviceToken(string $deviceToken)

Set the receiver of the message

Parameters

string $deviceToken Receiver of this message

Return Value

MessageBuilder

at line 40
MessageBuilder setCertificate(Certificate $certificate)

Set the certificate to use when

Parameters

Certificate $certificate The certificate that must be used for the APNS connection this message is send over

Return Value

MessageBuilder

at line 54
MessageBuilder setExpiresAt(DateTime $expiresAt = null)

Set the moment this message should expire or null if APNS should not store the message at all.

The last message for a device is stored at APNS for delivery until this moment if the device is offline.

Parameters

DateTime $expiresAt Date until the message should be stored for delivery

Return Value

MessageBuilder

at line 70
MessageBuilder setAlert(string|null $body, string|null $actionLocKey = null, string|null $launchImage = null)

Set the alert to display.

See also: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1

Parameters

string|null $body The text of the alert to display or null to set no alert
string|null $actionLocKey The localization key to use for the action button
string|null $launchImage The name of the launch image to use

Return Value

MessageBuilder

at line 105
MessageBuilder setAlertLocalized(string $locKey, array $locArgs = array(), string|null $actionLocKey = null, string|null $launchImage = null)

Set the localized alert to display.

See also: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1

Parameters

string $locKey The localization key to use for the text of the alert
array $locArgs The arguments that fill the gaps in the locKey text
string|null $actionLocKey The localization key to use for the action button
string|null $launchImage The name of the launch image to use

Return Value

MessageBuilder

at line 129
MessageBuilder addAlertAction(string $id, string $title)

Add custom (iOS 8+) actions to the alert you display Note: You must also call setAlert() or setAlertLocalized() to make a complete alert

Parameters

string $id The identifier of the custom action
string $title The text of the alert to display

Return Value

MessageBuilder

at line 144
MessageBuilder addAlertActionLocalized($id, $locKey, $locArgs = array())

Add localized custom (iOS 8+) actions to the alert you display Note: You must also call setAlert() or setAlertLocalized() to make a complete alert

Parameters

$id
$locKey
$locArgs

Return Value

MessageBuilder

at line 157
MessageBuilder setBadge(int|null $badge)

Set the badge to display on the App icon

Parameters

int|null $badge The badge number to display

Return Value

MessageBuilder

at line 169
MessageBuilder clearBadge()

Clear the badge from the App icon

Return Value

MessageBuilder

at line 182
MessageBuilder setSound(string $sound = 'default')

Set the sound that will be played when this message is received

Parameters

string $sound Optional string of the sound to play, no string will play the default sound

Return Value

MessageBuilder

at line 195
MessageBuilder setContentAvailable(boolean $contentAvailable)

Set newsstand content availability flag that will trigger the newsstand item to download new content

Parameters

boolean $contentAvailable True when new newsstand content is available, false when not

Return Value

MessageBuilder

at line 208
MessageBuilder setCategory(string $category)

Set the category identifier for this message used by the app to display custom actions

Parameters

string $category String of the category identifier

Return Value

MessageBuilder

at line 221
MessageBuilder setPayload(array|json|null $payload)

Set custom payload to go with the message

Parameters

array|json|null $payload The payload to send as array or JSON string

Return Value

MessageBuilder

at line 235
Message build()

Build the message

Return Value

Message

Exceptions

InvalidArgumentException On invalid or missing arguments
LengthException On too long message