public function packPayload($payload)
    {
        $payload = JsonEncoder::jsonEncode($payload);

        /** @var APNSMessage $message */
        $message = $this->message;

        $recipientId = $message->getRecipientDeviceCollection()->current()->getIdentifier();

        $messageRecipientId = $this->notificationId . '_' . $recipientId;

        $packedPayload =
            pack('C', 1). // Command push
            pack('N', $messageRecipientId).
            pack('N', $message->getExpirationTime()->format('U')).
            pack('n', 32). // Token binary length
            pack('H*', $recipientId);
        pack('n', strlen($payload));

        $packedPayload .= $payload;

        return $packedPayload;
    }
public function packPayload($payload)
    {
        $payload = JsonEncoder::jsonEncode($payload);

        /** @var APNSMessage $message */
        $message = $this->message;

        $recipientId = $message->getRecipientDeviceCollection()->current()->getIdentifier();

        $messageRecipientId = $this->notificationId . '_' . $recipientId;

        $packedPayload =
            pack('C', 1). // Command push
            pack('N', $messageRecipientId).
            pack('N', $message->getExpirationTime()->format('U')).
            pack('n', 32). // Token binary length
            pack('H*', $recipientId);
        pack('n', strlen($payload));

        $packedPayload .= $payload;

        return $packedPayload;
    }
public function packPayload ( $ payload ) { $ payload = JsonEncoder :: jsonEncode ( $ payload ) ; /** @var APNSMessage $message */ $ message = $ this -> message ; $ recipientId = $ message -> getRecipientDeviceCollection ( ) -> current ( ) -> getIdentifier ( ) ; $ messageRecipientId = $ this -> notificationId . '_' . $ recipientId ; $ packedPayload = pack ( 'C' , 1 ) . // Command push pack ( 'N' , $ messageRecipientId ) . pack ( 'N' , $ message -> getExpirationTime ( ) -> format ( 'U' ) ) . pack ( 'n' , 32 ) . // Token binary length pack ( 'H*' , $ recipientId ) ; pack ( 'n' , strlen ( $ payload ) ) ; $ packedPayload .= $ payload ; return $ packedPayload ; }
Pack message body into binary string

@param array $payload
@return string
Pack message body into binary string