Skip to content

Commit

Permalink
Merge pull request #1 from Jeroenwise/master
Browse files Browse the repository at this point in the history
The gcm endpoint url can now be set on the sender.
  • Loading branch information
christiaan committed Nov 19, 2014
2 parents 563f6d7 + 1e85a12 commit c66bcb3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/WebPower/gcm/server/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@ class Sender implements LoggerAwareInterface
private $logger;
/** @var HttpClient */
private $httpClient;
/** @var string */
private $GCMSendEndpoint;

public function __construct($key)
{
if (!$key) {
throw new \InvalidArgumentException();
}
$this->key = $key;

$this->GCMSendEndpoint = Constants::GCM_SEND_ENDPOINT;
}

/**
* @param string $url
*/
public function setEndPointUrl($url)
{
$this->GCMSendEndpoint = $url;
}

/**
Expand Down Expand Up @@ -177,7 +189,7 @@ public function sendNoRetry(Message $message, array $registrationIds)
}

$conn = $this->post(
Constants::GCM_SEND_ENDPOINT,
$this->GCMSendEndpoint,
"application/json",
$requestBody
);
Expand Down Expand Up @@ -302,7 +314,7 @@ public function singleSendNoRetry(Message $message, $registrationId)
if ($this->logger) {
$this->logger->debug('Request body: ' . $requestBody);
}
$conn = $this->post(Constants::GCM_SEND_ENDPOINT, "text/plain", $requestBody);
$conn = $this->post($this->GCMSendEndpoint, "text/plain", $requestBody);
$status = $conn->getResponseCode();
if ($status == 503) {
if ($this->logger) {
Expand Down

0 comments on commit c66bcb3

Please sign in to comment.