Skip to content

Commit 216aaac

Browse files
committed
rm any fcm reference
1 parent cacacf5 commit 216aaac

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/WebPush.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
class WebPush
2121
{
2222
const GCM_URL = 'https://android.googleapis.com/gcm/send';
23-
const FCM_URL = 'https://fcm.googleapis.com/fcm/send';
2423

2524
/** @var Browser */
2625
protected $browser;
@@ -212,19 +211,16 @@ private function prepareAndSend(array $notifications)
212211
$headers['Topic'] = $options['topic'];
213212
}
214213

215-
// if GCM or FCM url
216-
$isGCM = substr($endpoint, 0, strlen(self::GCM_URL)) === self::GCM_URL;
217-
if ($isGCM || substr($endpoint, 0, strlen(self::FCM_URL)) === self::FCM_URL) {
214+
// if GCM
215+
if (substr($endpoint, 0, strlen(self::GCM_URL)) === self::GCM_URL) {
218216
if (array_key_exists('GCM', $this->auth)) {
219217
$headers['Authorization'] = 'key='.$this->auth['GCM'];
220-
} elseif ($isGCM) {
221-
// FCM doesn't need an API key, it's optional if you're using VAPID
222-
throw new \ErrorException('No GCM/FCM API Key specified.');
218+
} else {
219+
throw new \ErrorException('No GCM API Key specified.');
223220
}
224221
}
225-
226222
// if VAPID (GCM doesn't support it but FCM does)
227-
if (array_key_exists('VAPID', $this->auth) && !$isGCM) {
223+
elseif (array_key_exists('VAPID', $this->auth)) {
228224
$vapid = $this->auth['VAPID'];
229225

230226
$audience = parse_url($endpoint, PHP_URL_SCHEME).'//'.parse_url($endpoint, PHP_URL_HOST);

tests/WebPushTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function testSendGCMNotificationWithoutGCMApiKey()
122122
{
123123
$webPush = new WebPush();
124124

125-
$this->setExpectedException('ErrorException', 'No GCM/FCM API Key specified.');
125+
$this->setExpectedException('ErrorException', 'No GCM API Key specified.');
126126
$webPush->sendNotification(self::$endpoints['GCM'], null, null, null, true);
127127
}
128128

0 commit comments

Comments
 (0)