src/Wrep/Notificato/Apns/Message.php
private function setPayload($payload)
	{
		if ( (is_string($payload) && empty($payload)) || (is_array($payload) && count($payload) == 0) )
		{
			// Empty strings or arrays are not allowed
			throw new \InvalidArgumentException('Invalid payload for message. Payload was empty, but not null)');
		}
		else if (is_array($payload) || null === $payload)
		{
			if ( isset($payload['aps']) )
			{
				// Reserved key is used
				throw new \InvalidArgumentException('Invalid payload for message. Custom payload may not contain the reserved "aps" key.');
			}
			else
			{
				// This is okay, set as payload
				$this->payload = $payload;
			}
		}
		else
		{
			// Try to decode JSON string payload
			$payload = json_decode($payload, true);

			// Check if decoding the payload worked
			if (null === $payload) {
				throw new \InvalidArgumentException('Invalid payload for message. Payload was invalid JSON.');
			}

			// Set as payload
			$this->payload = $payload;
		}
	}
private function setPayload($payload)
	{
		if ( (is_string($payload) && empty($payload)) || (is_array($payload) && count($payload) == 0) )
		{
			// Empty strings or arrays are not allowed
			throw new \InvalidArgumentException('Invalid payload for message. Payload was empty, but not null)');
		}
		else if (is_array($payload) || null === $payload)
		{
			if ( isset($payload['aps']) )
			{
				// Reserved key is used
				throw new \InvalidArgumentException('Invalid payload for message. Custom payload may not contain the reserved "aps" key.');
			}
			else
			{
				// This is okay, set as payload
				$this->payload = $payload;
			}
		}
		else
		{
			// Try to decode JSON string payload
			$payload = json_decode($payload, true);

			// Check if decoding the payload worked
			if (null === $payload) {
				throw new \InvalidArgumentException('Invalid payload for message. Payload was invalid JSON.');
			}

			// Set as payload
			$this->payload = $payload;
		}
	}
private function setPayload ( $ payload ) { if ( ( is_string ( $ payload ) && empty ( $ payload ) ) || ( is_array ( $ payload ) && count ( $ payload ) == 0 ) ) { // Empty strings or arrays are not allowed throw new \ InvalidArgumentException ( 'Invalid payload for message. Payload was empty, but not null)' ) ; } else if ( is_array ( $ payload ) || null === $ payload ) { if ( isset ( $ payload [ 'aps' ] ) ) { // Reserved key is used throw new \ InvalidArgumentException ( 'Invalid payload for message. Custom payload may not contain the reserved "aps" key.' ) ; } else { // This is okay, set as payload $ this -> payload = $ payload ; } } else { // Try to decode JSON string payload $ payload = json_decode ( $ payload , true ) ; // Check if decoding the payload worked if ( null === $ payload ) { throw new \ InvalidArgumentException ( 'Invalid payload for message. Payload was invalid JSON.' ) ; } // Set as payload $ this -> payload = $ payload ; } }
Set custom payload to go with the message

@param array|json|null The payload to send as array or JSON string
@throws \InvalidArgumentException On invalid or missing arguments
Set custom payload to go with the message