public function getJson()
	{
		// Get message and aps array to create JSON from
		$message = array();
		$aps = array();

		// If we have a payload replace the message object by the payload
		if (null !== $this->payload) {
			$message = $this->payload;
		}

		// Add the alert if any
		if (null !== $this->alert) {
			$aps['alert'] = $this->alert;
		}

		// Add the badge if any
		if (null !== $this->badge) {
			$aps['badge'] = $this->badge;
		}

		// Add the sound if any
		if (null !== $this->sound) {
			$aps['sound'] = $this->sound;
		}

		// Add category identifier if any
		if (null !== $this->category) {
			$aps['category'] = $this->category;
		}

		// Add the content-available flag if set
		if (true == $this->contentAvailable) {
			$aps['content-available'] = 1;
		}

		// Check if APS data is set
		if (count($aps) > 0) {
			$message['aps'] = $aps;
		}

		// Encode as JSON object
		$json = json_encode($message);
		if (false == $json) {
			throw new \RuntimeException('Failed to convert APNS\Message to JSON, are all strings UTF-8?', json_last_error());
		}

		return $json;
	}