RMS\PushNotificationsBundle\Service\OS\MicrosoftNotification::send PHP Метод

send() публичный Метод

public send ( RMS\PushNotificationsBundle\Message\MessageInterface $message )
$message RMS\PushNotificationsBundle\Message\MessageInterface
    public function send(MessageInterface $message)
    {
        if (!$message instanceof WindowsphoneMessage) {
            throw new InvalidMessageTypeException(sprintf("Message type '%s' not supported by MPNS", get_class($message)));
        }
        $headers = array('Content-Type: text/xml', 'X-WindowsPhone-Target: ' . $message->getTarget(), 'X-NotificationClass: ' . $message->getNotificationClass());
        $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><wp:Notification xmlns:wp="WPNotification" />');
        $msgBody = $message->getMessageBody();
        if ($message->getTarget() == WindowsphoneMessage::TYPE_TOAST) {
            $toast = $xml->addChild('wp:Toast');
            $toast->addChild('wp:Text1', htmlspecialchars($msgBody['text1'], ENT_XML1 | ENT_QUOTES));
            $toast->addChild('wp:Text2', htmlspecialchars($msgBody['text2'], ENT_XML1 | ENT_QUOTES));
        }
        $response = $this->browser->post($message->getDeviceIdentifier(), $headers, $xml->asXML());
        if (!$response->isSuccessful()) {
            $this->logger->error($response->getStatusCode() . ' : ' . $response->getReasonPhrase());
        }
        return $response->isSuccessful();
    }
MicrosoftNotification