PHP Class RMS\PushNotificationsBundle\Service\OS\AppleNotification

Inheritance: implements RMS\PushNotificationsBundle\Service\OS\OSNotificationServiceInterface
Show file Open project: richsage/RMSPushNotificationsBundle Class Usage Examples

Protected Properties

Property Type Description
$apnStreams array Array for streams to APN
$cachedir string Cache dir used for cache pem file
$jsonUnescapedUnicode boolean JSON_UNESCAPED_UNICODE
$lastMessageId integer Last used message ID
$logger Psr\Log\LoggerInterface Monolog logger
$messages array Array for messages to APN
$passphrase string Passphrase for PEM file
$pemContent string Content of PEM
$pemContentPassphrase string Passphrase for PEM content
$pemPath string Path to PEM file
$responses array Collection of the responses from the APN
$timeout integer Connection timeout
$useSandbox boolean Whether or not to use the sandbox APNS

Public Methods

Method Description
__construct ( boolean $sandbox, string $pem, string $passphrase = "", boolean $jsonUnescapedUnicode = FALSE, integer $timeout = 60, string $cachedir = "", RMS\PushNotificationsBundle\Service\EventListener $eventListener = null, Psr\Log\LoggerInterface $logger = null ) Constructor
createMdmPayload ( string $token, string $magicPushToken ) : string Creates a MDM payload
getResponses ( ) : array Returns responses
onKernelTerminate ( ) Called on kernel terminate
send ( RMS\PushNotificationsBundle\Message\MessageInterface $message ) : boolean Send a MDM or notification message
setJsonUnescapedUnicode ( boolean $jsonUnescapedUnicode ) Set option JSON_UNESCAPED_UNICODE to json encoders
setPemAsString ( $pemContent, $passphrase )

Protected Methods

Method Description
closeApnStream ( string $apnURL ) Close the apn stream associated with the given apn URL
createPayload ( integer $messageId, string $expiry, string $token, array $message ) : string Creates the full payload for the notification
getApnStream ( string $apnURL ) : resource Get an apn stream associated with the given apn URL, create one if necessary
getStreamContext ( ) : resource Gets a stream context set up for SSL using our PEM file and passphrase
sendMessages ( integer $firstMessageId, string $apnURL ) : integer Send all notification messages starting from the given ID
writeApnStream ( string $apnURL, string $payload ) : mixed Write data to the apn stream that is associated with the given apn URL

Private Methods

Method Description
closeStreams ( ) Close existing streams
removeCachedPemFile ( ) Remove cache pem file

Method Details

__construct() public method

Constructor
public __construct ( boolean $sandbox, string $pem, string $passphrase = "", boolean $jsonUnescapedUnicode = FALSE, integer $timeout = 60, string $cachedir = "", RMS\PushNotificationsBundle\Service\EventListener $eventListener = null, Psr\Log\LoggerInterface $logger = null )
$sandbox boolean
$pem string
$passphrase string
$jsonUnescapedUnicode boolean
$timeout integer
$cachedir string
$eventListener RMS\PushNotificationsBundle\Service\EventListener
$logger Psr\Log\LoggerInterface

closeApnStream() protected method

Close the apn stream associated with the given apn URL
protected closeApnStream ( string $apnURL )
$apnURL string

createMdmPayload() public method

Creates a MDM payload
public createMdmPayload ( string $token, string $magicPushToken ) : string
$token string
$magicPushToken string
return string

createPayload() protected method

Creates the full payload for the notification
protected createPayload ( integer $messageId, string $expiry, string $token, array $message ) : string
$messageId integer
$expiry string
$token string
$message array
return string

getApnStream() protected method

Get an apn stream associated with the given apn URL, create one if necessary
protected getApnStream ( string $apnURL ) : resource
$apnURL string
return resource

getResponses() public method

Returns responses
public getResponses ( ) : array
return array

getStreamContext() protected method

Gets a stream context set up for SSL using our PEM file and passphrase
protected getStreamContext ( ) : resource
return resource

onKernelTerminate() public method

Called on kernel terminate
public onKernelTerminate ( )

send() public method

Send a MDM or notification message
public send ( RMS\PushNotificationsBundle\Message\MessageInterface $message ) : boolean
$message RMS\PushNotificationsBundle\Message\MessageInterface
return boolean

sendMessages() protected method

Send all notification messages starting from the given ID
protected sendMessages ( integer $firstMessageId, string $apnURL ) : integer
$firstMessageId integer
$apnURL string
return integer

setJsonUnescapedUnicode() public method

Set option JSON_UNESCAPED_UNICODE to json encoders
public setJsonUnescapedUnicode ( boolean $jsonUnescapedUnicode )
$jsonUnescapedUnicode boolean

setPemAsString() public method

public setPemAsString ( $pemContent, $passphrase )
$pemContent
$passphrase

writeApnStream() protected method

Write data to the apn stream that is associated with the given apn URL
protected writeApnStream ( string $apnURL, string $payload ) : mixed
$apnURL string
$payload string
return mixed

Property Details

$apnStreams protected property

Array for streams to APN
protected array $apnStreams
return array

$cachedir protected property

Cache dir used for cache pem file
protected string $cachedir
return string

$jsonUnescapedUnicode protected property

JSON_UNESCAPED_UNICODE
protected bool $jsonUnescapedUnicode
return boolean

$lastMessageId protected property

Last used message ID
protected int $lastMessageId
return integer

$logger protected property

Monolog logger
protected LoggerInterface,Psr\Log $logger
return Psr\Log\LoggerInterface

$messages protected property

Array for messages to APN
protected array $messages
return array

$passphrase protected property

Passphrase for PEM file
protected string $passphrase
return string

$pemContent protected property

Content of PEM
protected string $pemContent
return string

$pemContentPassphrase protected property

Passphrase for PEM content
protected string $pemContentPassphrase
return string

$pemPath protected property

Path to PEM file
protected string $pemPath
return string

$responses protected property

Collection of the responses from the APN
protected array $responses
return array

$timeout protected property

Connection timeout
protected int $timeout
return integer

$useSandbox protected property

Whether or not to use the sandbox APNS
protected bool $useSandbox
return boolean