public function send(MessageInterface $message)
    {
        if (!$message instanceof AppleMessage) {
            throw new InvalidMessageTypeException(sprintf("Message type '%s' not supported by APN", get_class($message)));
        }

        $apnURL = "ssl://gateway.push.apple.com:2195";
        if ($this->useSandbox) {
            $apnURL = "ssl://gateway.sandbox.push.apple.com:2195";
        }

        $messageId = ++$this->lastMessageId;

        if ($message->isMdmMessage()) {
            if ($message->getToken() == '') {
                throw new InvalidMessageTypeException(sprintf("Message type '%s' is a MDM message but 'token' is missing", get_class($message)));
            }

            if ($message->getPushMagicToken() == '') {
                throw new InvalidMessageTypeException(sprintf("Message type '%s' is a MDM message but 'pushMagicToken' is missing", get_class($message)));
            }

            $this->messages[$messageId] = $this->createMdmPayload($message->getToken(), $message->getPushMagicToken());
        } else {
            $this->messages[$messageId] = $this->createPayload($messageId, $message->getExpiry(), $message->getDeviceIdentifier(), $message->getMessageBody());
        }

        $errors = $this->sendMessages($messageId, $apnURL);

        return !$errors;
    }
public function send(MessageInterface $message)
    {
        if (!$message instanceof AppleMessage) {
            throw new InvalidMessageTypeException(sprintf("Message type '%s' not supported by APN", get_class($message)));
        }

        $apnURL = "ssl://gateway.push.apple.com:2195";
        if ($this->useSandbox) {
            $apnURL = "ssl://gateway.sandbox.push.apple.com:2195";
        }

        $messageId = ++$this->lastMessageId;

        if ($message->isMdmMessage()) {
            if ($message->getToken() == '') {
                throw new InvalidMessageTypeException(sprintf("Message type '%s' is a MDM message but 'token' is missing", get_class($message)));
            }

            if ($message->getPushMagicToken() == '') {
                throw new InvalidMessageTypeException(sprintf("Message type '%s' is a MDM message but 'pushMagicToken' is missing", get_class($message)));
            }

            $this->messages[$messageId] = $this->createMdmPayload($message->getToken(), $message->getPushMagicToken());
        } else {
            $this->messages[$messageId] = $this->createPayload($messageId, $message->getExpiry(), $message->getDeviceIdentifier(), $message->getMessageBody());
        }

        $errors = $this->sendMessages($messageId, $apnURL);

        return !$errors;
    }
public function send ( MessageInterface $ message ) { if ( ! $ message instanceof AppleMessage ) { throw new InvalidMessageTypeException ( sprintf ( "Message type '%s' not supported by APN" , get_class ( $ message ) ) ) ; } $ apnURL = "ssl://gateway.push.apple.com:2195" ; if ( $ this -> useSandbox ) { $ apnURL = "ssl://gateway.sandbox.push.apple.com:2195" ; } $ messageId = ++ $ this -> lastMessageId ; if ( $ message -> isMdmMessage ( ) ) { if ( $ message -> getToken ( ) == '' ) { throw new InvalidMessageTypeException ( sprintf ( "Message type '%s' is a MDM message but 'token' is missing" , get_class ( $ message ) ) ) ; } if ( $ message -> getPushMagicToken ( ) == '' ) { throw new InvalidMessageTypeException ( sprintf ( "Message type '%s' is a MDM message but 'pushMagicToken' is missing" , get_class ( $ message ) ) ) ; } $ this -> messages [ $ messageId ] = $ this -> createMdmPayload ( $ message -> getToken ( ) , $ message -> getPushMagicToken ( ) ) ; } else { $ this -> messages [ $ messageId ] = $ this -> createPayload ( $ messageId , $ message -> getExpiry ( ) , $ message -> getDeviceIdentifier ( ) , $ message -> getMessageBody ( ) ) ; } $ errors = $ this -> sendMessages ( $ messageId , $ apnURL ) ; return ! $ errors ; }
Send a MDM or notification message

@param  \RMS\PushNotificationsBundle\Message\MessageInterface|\RMS\PushNotificationsBundle\Service\OS\MessageInterface $message
@throws \RuntimeException
@throws \RMS\PushNotificationsBundle\Exception\InvalidMessageTypeException
@return bool
Send a MDM or notification message