diff --git a/src/PubNub/Endpoints/Push/AddChannelsToPush.php b/src/PubNub/Endpoints/Push/AddChannelsToPush.php index de62a564..aac20698 100644 --- a/src/PubNub/Endpoints/Push/AddChannelsToPush.php +++ b/src/PubNub/Endpoints/Push/AddChannelsToPush.php @@ -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; diff --git a/src/PubNub/Endpoints/Push/ListPushProvisions.php b/src/PubNub/Endpoints/Push/ListPushProvisions.php index 33a7209e..0c2cad8f 100644 --- a/src/PubNub/Endpoints/Push/ListPushProvisions.php +++ b/src/PubNub/Endpoints/Push/ListPushProvisions.php @@ -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 @@ -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; diff --git a/src/PubNub/Endpoints/Push/PushEndpoint.php b/src/PubNub/Endpoints/Push/PushEndpoint.php index 44aa85cf..767e4e31 100644 --- a/src/PubNub/Endpoints/Push/PushEndpoint.php +++ b/src/PubNub/Endpoints/Push/PushEndpoint.php @@ -146,4 +146,9 @@ protected function getName() { return static::OPERATION_NAME; } + + protected function getPushType(): string + { + return $this->pushType == PNPushType::FCM ? 'gcm' : $this->pushType; + } } diff --git a/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php b/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php index 0a793592..90646c44 100644 --- a/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php +++ b/src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php @@ -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; diff --git a/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php b/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php index 1d841f52..90ff0978 100644 --- a/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php +++ b/src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php @@ -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 @@ -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; diff --git a/tests/functional/push/AddChannelsToPushTest.php b/tests/functional/push/AddChannelsToPushTest.php index fe2669c5..71e9f34c 100644 --- a/tests/functional/push/AddChannelsToPushTest.php +++ b/tests/functional/push/AddChannelsToPushTest.php @@ -110,7 +110,7 @@ public function testPushAddFCM() $this->assertEquals([ "pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()), "uuid" => $this->pubnub->getConfiguration()->getUuid(), - "type" => "fcm", + "type" => "gcm", "add" => "ch1,ch2,ch3" ], $add->buildParams()); diff --git a/tests/functional/push/ListPushProvisionsTest.php b/tests/functional/push/ListPushProvisionsTest.php index d42f15a7..e0ae5733 100644 --- a/tests/functional/push/ListPushProvisionsTest.php +++ b/tests/functional/push/ListPushProvisionsTest.php @@ -76,7 +76,7 @@ public function testListChannelGroupFCM() $this->assertEquals([ "pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()), "uuid" => $this->pubnub->getConfiguration()->getUuid(), - "type" => "fcm" + "type" => "gcm" ], $list->buildParams()); } diff --git a/tests/functional/push/RemoveChannelsFromPushTest.php b/tests/functional/push/RemoveChannelsFromPushTest.php index 486ef96d..d801d13d 100644 --- a/tests/functional/push/RemoveChannelsFromPushTest.php +++ b/tests/functional/push/RemoveChannelsFromPushTest.php @@ -77,7 +77,7 @@ public function testPushRemoveFCM() $this->assertEquals([ "pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()), "uuid" => $this->pubnub->getConfiguration()->getUuid(), - "type" => "fcm", + "type" => "gcm", "remove" => "ch1,ch2,ch3" ], $remove->buildParams()); } diff --git a/tests/functional/push/RemoveDeviceFromPushTest.php b/tests/functional/push/RemoveDeviceFromPushTest.php index a95938df..02c6dd80 100644 --- a/tests/functional/push/RemoveDeviceFromPushTest.php +++ b/tests/functional/push/RemoveDeviceFromPushTest.php @@ -72,7 +72,7 @@ public function testRemovePushFCM() $this->assertEquals([ "pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()), "uuid" => $this->pubnub->getConfiguration()->getUuid(), - "type" => "fcm", + "type" => "gcm", ], $remove->buildParams()); } } diff --git a/tests/integrational/ListPushProvisionsTest.php b/tests/integrational/ListPushProvisionsTest.php index 696b4bfb..89e51d18 100644 --- a/tests/integrational/ListPushProvisionsTest.php +++ b/tests/integrational/ListPushProvisionsTest.php @@ -39,7 +39,7 @@ public function testFCMSuccess() $list->stubFor("/v1/push/sub-key/demo/devices/coolDevice") ->withQuery([ - "type" => "fcm", + "type" => "gcm", "pnsdk" => $this->encodedSdkName, "uuid" => "sampleUUID" ]) diff --git a/tests/integrational/ModifyPushChannelsForDeviceTest.php b/tests/integrational/ModifyPushChannelsForDeviceTest.php index 59c1eea0..3a3a6f39 100644 --- a/tests/integrational/ModifyPushChannelsForDeviceTest.php +++ b/tests/integrational/ModifyPushChannelsForDeviceTest.php @@ -41,7 +41,7 @@ public function testFCMSuccessRemoveAll() $listRemove->stubFor("/v1/push/sub-key/demo/devices/coolDevice/remove") ->withQuery([ - "type" => "fcm", + "type" => "gcm", "pnsdk" => $this->encodedSdkName, "uuid" => "sampleUUID" ]) @@ -200,7 +200,7 @@ public function testAddFCMSuccessSync() $listAdd->stubFor("/v1/push/sub-key/demo/devices/coolDevice") ->withQuery([ "add" => "ch1,ch2,ch3", - "type" => "fcm", + "type" => "gcm", "pnsdk" => $this->encodedSdkName, "uuid" => "sampleUUID" ]) @@ -383,7 +383,7 @@ public function testFCMSuccessRemove() $remove->stubFor("/v1/push/sub-key/demo/devices/coolDevice") ->withQuery([ "remove" => "ch1,ch2,ch3", - "type" => "fcm", + "type" => "gcm", "pnsdk" => $this->encodedSdkName, "uuid" => "sampleUUID" ]) diff --git a/tests/integrational/push/AddChannelsToPushEndpointTest.php b/tests/integrational/push/AddChannelsToPushEndpointTest.php index 78fd16b1..4c0a24bb 100644 --- a/tests/integrational/push/AddChannelsToPushEndpointTest.php +++ b/tests/integrational/push/AddChannelsToPushEndpointTest.php @@ -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"]'); diff --git a/tests/integrational/push/ListPushProvisionsEndpointTest.php b/tests/integrational/push/ListPushProvisionsEndpointTest.php index 8b1977cc..8a750da9 100644 --- a/tests/integrational/push/ListPushProvisionsEndpointTest.php +++ b/tests/integrational/push/ListPushProvisionsEndpointTest.php @@ -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"]'); diff --git a/tests/integrational/push/RemoveChannelsFromPushEndpointTest.php b/tests/integrational/push/RemoveChannelsFromPushEndpointTest.php index 698defcd..2bd090e8 100644 --- a/tests/integrational/push/RemoveChannelsFromPushEndpointTest.php +++ b/tests/integrational/push/RemoveChannelsFromPushEndpointTest.php @@ -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" ]) diff --git a/tests/integrational/push/RemoveDeviceFromPushEndpointTest.php b/tests/integrational/push/RemoveDeviceFromPushEndpointTest.php index 0e94f98f..5d26aa34 100644 --- a/tests/integrational/push/RemoveDeviceFromPushEndpointTest.php +++ b/tests/integrational/push/RemoveDeviceFromPushEndpointTest.php @@ -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"]');