Skip to content

Commit

Permalink
FCM sends GCM as a type parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
seba-aln committed Jun 11, 2024
1 parent d3d7729 commit ea00ed5
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/PubNub/Endpoints/Push/AddChannelsToPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ protected function customParams()
];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
4 changes: 1 addition & 3 deletions src/PubNub/Endpoints/Push/ListPushProvisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use PubNub\Enums\PNHttpMethod;
use PubNub\Enums\PNOperationType;
use PubNub\Enums\PNPushType;
use PubNub\Exceptions\PubNubValidationException;
use PubNub\Models\Consumer\Push\PNPushListProvisionsResult;

class ListPushProvisions extends PushEndpoint
Expand All @@ -23,8 +22,7 @@ protected function customParams()
$params = [];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
5 changes: 5 additions & 0 deletions src/PubNub/Endpoints/Push/PushEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,9 @@ protected function getName()
{
return static::OPERATION_NAME;
}

protected function getPushType(): string
{
return $this->pushType == PNPushType::FCM ? 'gcm' : $this->pushType;
}
}
3 changes: 1 addition & 2 deletions src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ protected function customParams()
];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
4 changes: 1 addition & 3 deletions src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PubNub\Enums\PNHttpMethod;
use PubNub\Enums\PNOperationType;
use PubNub\Enums\PNPushType;
use PubNub\Exceptions\PubNubValidationException;
use PubNub\Models\Consumer\Push\PNPushRemoveAllChannelsResult;

class RemoveDeviceFromPush extends PushEndpoint
Expand All @@ -24,8 +23,7 @@ protected function customParams()
$params = [];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
2 changes: 1 addition & 1 deletion tests/integrational/push/AddChannelsToPushEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testPushAddFCM()
->withQuery([
"pnsdk" => $this->encodedSdkName,
"add" => "ch1,ch2,ch3",
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
])
->setResponseBody('[1, "Modified Channels"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testListChannelGroupFCM()
$list->stubFor("/v1/push/sub-key/demo/devices/coolDevice")
->withQuery([
"pnsdk" => $this->encodedSdkName,
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
])
->setResponseBody('[1, "Modified Channels"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testPushRemoveFCM()
$remove->stubFor("/v1/push/sub-key/demo/devices/coolDevice")
->withQuery([
"pnsdk" => $this->encodedSdkName,
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
"remove" => "ch1,ch2,ch3"
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testRemovePushFCM()
$remove->stubFor("/v1/push/sub-key/demo/devices/coolDevice/remove")
->withQuery([
"pnsdk" => $this->encodedSdkName,
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
])
->setResponseBody('[1, "Modified Channels"]');
Expand Down

0 comments on commit ea00ed5

Please sign in to comment.