Skip to content

Commit c66bcb3

Browse files
committed
Merge pull request #1 from Jeroenwise/master
The gcm endpoint url can now be set on the sender.
2 parents 563f6d7 + 1e85a12 commit c66bcb3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/WebPower/gcm/server/Sender.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,25 @@ class Sender implements LoggerAwareInterface
2121
private $logger;
2222
/** @var HttpClient */
2323
private $httpClient;
24+
/** @var string */
25+
private $GCMSendEndpoint;
2426

2527
public function __construct($key)
2628
{
2729
if (!$key) {
2830
throw new \InvalidArgumentException();
2931
}
3032
$this->key = $key;
33+
34+
$this->GCMSendEndpoint = Constants::GCM_SEND_ENDPOINT;
35+
}
36+
37+
/**
38+
* @param string $url
39+
*/
40+
public function setEndPointUrl($url)
41+
{
42+
$this->GCMSendEndpoint = $url;
3143
}
3244

3345
/**
@@ -177,7 +189,7 @@ public function sendNoRetry(Message $message, array $registrationIds)
177189
}
178190

179191
$conn = $this->post(
180-
Constants::GCM_SEND_ENDPOINT,
192+
$this->GCMSendEndpoint,
181193
"application/json",
182194
$requestBody
183195
);
@@ -302,7 +314,7 @@ public function singleSendNoRetry(Message $message, $registrationId)
302314
if ($this->logger) {
303315
$this->logger->debug('Request body: ' . $requestBody);
304316
}
305-
$conn = $this->post(Constants::GCM_SEND_ENDPOINT, "text/plain", $requestBody);
317+
$conn = $this->post($this->GCMSendEndpoint, "text/plain", $requestBody);
306318
$status = $conn->getResponseCode();
307319
if ($status == 503) {
308320
if ($this->logger) {

0 commit comments

Comments
 (0)