RMS\PushNotificationsBundle\Service\OS\AppleNotification::writeApnStream PHP Method

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
    protected function writeApnStream($apnURL, $payload)
    {
        // Get the correct Apn stream and send data
        $fp = $this->getApnStream($apnURL);
        $response = strlen($payload) === @fwrite($fp, $payload, strlen($payload));
        // Check if there is responsedata to read
        $readStreams = array($fp);
        $null = NULL;
        $streamsReadyToRead = @stream_select($readStreams, $null, $null, 1, 0);
        if ($streamsReadyToRead > 0) {
            // Unpack error response data and set as the result
            $response = @unpack("Ccommand/Cstatus/Nidentifier", fread($fp, 6));
            $this->closeApnStream($apnURL);
        }
        // Will contain true if writing succeeded and no error is returned yet
        return $response;
    }