Skip to content

Commit f166eba

Browse files
Mohit TejaniMohit Tejani
authored andcommitted
replace gcm with fcm for push notification gateway type. since google stopped supporting gcm
1 parent d8b92af commit f166eba

11 files changed

Lines changed: 66 additions & 66 deletions

File tree

docs-snippets/basic-usage/mobile-push.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ try {
3131
const response = await pubnub.push.addChannels({
3232
channels: ['a', 'b'],
3333
device: 'niceDevice',
34-
pushGateway: 'gcm',
34+
pushGateway: 'fcm',
3535
});
3636
console.log('device added to channels response:', response);
3737
} catch (error) {
@@ -68,7 +68,7 @@ try {
6868
try {
6969
const response = await pubnub.push.listChannels({
7070
device: 'niceDevice',
71-
pushGateway: 'gcm',
71+
pushGateway: 'fcm',
7272
});
7373

7474
console.log('listing channels for device response:', response);
@@ -110,7 +110,7 @@ try {
110110
const response = await pubnub.push.removeChannels({
111111
channels: ['a', 'b'],
112112
device: 'niceDevice',
113-
pushGateway: 'gcm',
113+
pushGateway: 'fcm',
114114
});
115115

116116
console.log('removing device from channel response:', response);
@@ -147,7 +147,7 @@ try {
147147
try {
148148
const response = await pubnub.push.deleteDevice({
149149
device: 'niceDevice',
150-
pushGateway: 'gcm',
150+
pushGateway: 'fcm',
151151
});
152152

153153
console.log('deleteDevice response:', response);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/endpoints/push/push.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class BasePushNotificationChannelsRequest<R, S extends object> extends Ab
8080
)
8181
return 'Missing Channels';
8282

83-
if (!pushGateway) return 'Missing GW Type (pushGateway: gcm or apns2)';
83+
if (!pushGateway) return 'Missing GW Type (pushGateway: fcm or apns2)';
8484
if (this.parameters.pushGateway === 'apns2' && !this.parameters.topic) return 'Missing APNS2 topic';
8585
}
8686

src/core/types/api/push-notifications.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Type of Push Notifications gateway which should be used with Push Notifications REST API.
33
*/
4-
type PushGateway = 'apns2' | 'gcm';
4+
type PushGateway = 'apns2' | 'fcm';
55

66
/**
77
* Basic information required by Push Notifications REST API about device.
@@ -16,8 +16,8 @@ type DevicePush = {
1616
* Push Notifications gateway to use.
1717
*
1818
* **Important:** Depends on from the source of `device` token and can be `apns2` (for token
19-
* provided during device registration using Apple's framework) or `gcm` (when used Firebase
20-
* or similar framework to receive token).
19+
* provided during device registration using Apple's framework) or `fcm` (when used Firebase
20+
* Cloud Messaging or similar framework to receive token).
2121
*/
2222
pushGateway: PushGateway;
2323
};

src/core/types/api/push.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type ManageFCMDeviceChannelsParameters = ManagedDeviceChannels & {
7474
/**
7575
* Push Notifications gateway type.
7676
*/
77-
pushGateway: 'gcm';
77+
pushGateway: 'fcm';
7878
};
7979

8080
/**

test/integration/endpoints/push.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ describe('push endpoints', () => {
8888
.query({
8989
add: 'a,b',
9090
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
91-
type: 'gcm',
91+
type: 'fcm',
9292
uuid: 'myUUID',
9393
})
9494
.reply(200, '[1, "Modified Channels"]', { 'content-type': 'text/javascript' });
9595

96-
pubnub.push.addChannels({ channels: ['a', 'b'], device: 'niceDevice', pushGateway: 'gcm' }, (status) => {
96+
pubnub.push.addChannels({ channels: ['a', 'b'], device: 'niceDevice', pushGateway: 'fcm' }, (status) => {
9797
try {
9898
assert.equal(status.error, false);
9999
assert.equal(scope.isDone(), true);
@@ -165,12 +165,12 @@ describe('push endpoints', () => {
165165
.get('/v1/push/sub-key/mySubKey/devices/coolDevice')
166166
.query({
167167
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
168-
type: 'gcm',
168+
type: 'fcm',
169169
uuid: 'myUUID',
170170
})
171171
.reply(200, '["ch1", "ch2", "ch3"]', { 'content-type': 'text/javascript' });
172172

173-
pubnub.push.listChannels({ device: 'coolDevice', pushGateway: 'gcm' }, (status, response) => {
173+
pubnub.push.listChannels({ device: 'coolDevice', pushGateway: 'fcm' }, (status, response) => {
174174
try {
175175
assert.equal(status.error, false);
176176
assert(response !== null);
@@ -243,7 +243,7 @@ describe('push endpoints', () => {
243243
.query({
244244
remove: 'a,b',
245245
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
246-
type: 'gcm',
246+
type: 'fcm',
247247
uuid: 'myUUID',
248248
})
249249
.reply(200, '[1, "Modified Channels"]', { 'content-type': 'text/javascript' });
@@ -252,7 +252,7 @@ describe('push endpoints', () => {
252252
{
253253
channels: ['a', 'b'],
254254
device: 'niceDevice',
255-
pushGateway: 'gcm',
255+
pushGateway: 'fcm',
256256
},
257257
(status) => {
258258
try {
@@ -323,12 +323,12 @@ describe('push endpoints', () => {
323323
.get('/v1/push/sub-key/mySubKey/devices/niceDevice/remove')
324324
.query({
325325
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
326-
type: 'gcm',
326+
type: 'fcm',
327327
uuid: 'myUUID',
328328
})
329329
.reply(200, '[1, "Modified Channels"]', { 'content-type': 'text/javascript' });
330330

331-
pubnub.push.deleteDevice({ device: 'niceDevice', pushGateway: 'gcm' }, (status) => {
331+
pubnub.push.deleteDevice({ device: 'niceDevice', pushGateway: 'fcm' }, (status) => {
332332
try {
333333
assert.equal(status.error, false);
334334
assert.equal(scope.isDone(), true);

test/unit/push_notification/push_add_channels.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('AddDevicePushNotificationChannelsRequest', () => {
1919

2020
defaultParameters = {
2121
device: 'test_device_id',
22-
pushGateway: 'gcm',
22+
pushGateway: 'fcm',
2323
channels: ['channel1', 'channel2'],
2424
keySet: defaultKeySet,
2525
};
@@ -55,7 +55,7 @@ describe('AddDevicePushNotificationChannelsRequest', () => {
5555
...defaultParameters,
5656
pushGateway: undefined,
5757
});
58-
assert.equal(request.validate(), 'Missing GW Type (pushGateway: gcm or apns2)');
58+
assert.equal(request.validate(), 'Missing GW Type (pushGateway: fcm or apns2)');
5959
});
6060

6161
it('should validate APNS2 topic when using apns2', () => {
@@ -90,7 +90,7 @@ describe('AddDevicePushNotificationChannelsRequest', () => {
9090
});
9191

9292
describe('path construction', () => {
93-
it('should construct path for GCM', () => {
93+
it('should construct path for FCM', () => {
9494
const request = new AddDevicePushNotificationChannelsRequest(defaultParameters);
9595
const transportRequest = request.request();
9696
const expectedPath = `/v1/push/sub-key/${defaultKeySet.subscribeKey}/devices/${defaultParameters.device}`;
@@ -110,11 +110,11 @@ describe('AddDevicePushNotificationChannelsRequest', () => {
110110
});
111111

112112
describe('query parameters', () => {
113-
it('should include required query parameters for GCM', () => {
113+
it('should include required query parameters for FCM', () => {
114114
const request = new AddDevicePushNotificationChannelsRequest(defaultParameters);
115115
const transportRequest = request.request();
116116

117-
assert.equal(transportRequest.queryParameters?.type, 'gcm');
117+
assert.equal(transportRequest.queryParameters?.type, 'fcm');
118118
assert.equal(transportRequest.queryParameters?.add, 'channel1,channel2');
119119
assert.equal(transportRequest.queryParameters?.environment, undefined);
120120
assert.equal(transportRequest.queryParameters?.topic, undefined);
@@ -244,7 +244,7 @@ describe('AddDevicePushNotificationChannelsRequest', () => {
244244
it('should not set environment for GCM', () => {
245245
const request = new AddDevicePushNotificationChannelsRequest({
246246
...defaultParameters,
247-
pushGateway: 'gcm',
247+
pushGateway: 'fcm',
248248
environment: 'production', // Should be ignored for GCM
249249
});
250250
const transportRequest = request.request();

test/unit/push_notification/push_base.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('BasePushNotificationChannelsRequest', () => {
3434

3535
defaultParameters = {
3636
device: 'test_device_id',
37-
pushGateway: 'gcm',
37+
pushGateway: 'fcm',
3838
channels: ['channel1', 'channel2'],
3939
keySet: defaultKeySet,
4040
action: 'add',
@@ -115,15 +115,15 @@ describe('BasePushNotificationChannelsRequest', () => {
115115
...defaultParameters,
116116
pushGateway: undefined,
117117
});
118-
assert.equal(request.validate(), 'Missing GW Type (pushGateway: gcm or apns2)');
118+
assert.equal(request.validate(), 'Missing GW Type (pushGateway: fcm or apns2)');
119119
});
120120

121121
it('should validate missing pushGateway', () => {
122122
const request = new TestPushNotificationRequest({
123123
...defaultParameters,
124124
pushGateway: '',
125125
});
126-
assert.equal(request.validate(), 'Missing GW Type (pushGateway: gcm or apns2)');
126+
assert.equal(request.validate(), 'Missing GW Type (pushGateway: fcm or apns2)');
127127
});
128128

129129
it('should validate APNS2 topic when using apns2', () => {
@@ -144,7 +144,7 @@ describe('BasePushNotificationChannelsRequest', () => {
144144
assert.equal(request.validate(), 'Missing APNS2 topic');
145145
});
146146

147-
it('should pass validation with valid GCM parameters', () => {
147+
it('should pass validation with valid FCM parameters', () => {
148148
const request = new TestPushNotificationRequest(defaultParameters);
149149
assert.equal(request.validate(), undefined);
150150
});
@@ -202,11 +202,11 @@ describe('BasePushNotificationChannelsRequest', () => {
202202
});
203203

204204
describe('query parameters', () => {
205-
it('should include type parameter for GCM', () => {
205+
it('should include type parameter for FCM', () => {
206206
const request = new TestPushNotificationRequest(defaultParameters);
207207
const transportRequest = request.request();
208-
209-
assert.equal(transportRequest.queryParameters?.type, 'gcm');
208+
209+
assert.equal(transportRequest.queryParameters?.type, 'fcm');
210210
});
211211

212212
it('should include type parameter for APNS2', () => {
@@ -290,10 +290,10 @@ describe('BasePushNotificationChannelsRequest', () => {
290290
assert.equal(transportRequest.queryParameters?.environment, 'development');
291291
});
292292

293-
it('should not include environment for GCM', () => {
293+
it('should not include environment for FCM', () => {
294294
const request = new TestPushNotificationRequest({
295295
...defaultParameters,
296-
pushGateway: 'gcm',
296+
pushGateway: 'fcm',
297297
environment: 'production',
298298
});
299299
const transportRequest = request.request();

test/unit/push_notification/push_list_channels.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('ListDevicePushNotificationChannelsRequest', () => {
1919

2020
defaultParameters = {
2121
device: 'test_device_id',
22-
pushGateway: 'gcm',
22+
pushGateway: 'fcm',
2323
keySet: defaultKeySet,
2424
};
2525
});
@@ -46,7 +46,7 @@ describe('ListDevicePushNotificationChannelsRequest', () => {
4646
...defaultParameters,
4747
pushGateway: undefined,
4848
});
49-
assert.equal(request.validate(), 'Missing GW Type (pushGateway: gcm or apns2)');
49+
assert.equal(request.validate(), 'Missing GW Type (pushGateway: fcm or apns2)');
5050
});
5151

5252
it('should validate APNS2 topic when using apns2', () => {
@@ -58,7 +58,7 @@ describe('ListDevicePushNotificationChannelsRequest', () => {
5858
assert.equal(request.validate(), 'Missing APNS2 topic');
5959
});
6060

61-
it('should pass validation with valid GCM parameters', () => {
61+
it('should pass validation with valid FCM parameters', () => {
6262
const request = new ListDevicePushNotificationChannelsRequest(defaultParameters);
6363
assert.equal(request.validate(), undefined);
6464
});
@@ -87,7 +87,7 @@ describe('ListDevicePushNotificationChannelsRequest', () => {
8787
});
8888

8989
describe('path construction', () => {
90-
it('should construct path for GCM', () => {
90+
it('should construct path for FCM', () => {
9191
const request = new ListDevicePushNotificationChannelsRequest(defaultParameters);
9292
const transportRequest = request.request();
9393
const expectedPath = `/v1/push/sub-key/${defaultKeySet.subscribeKey}/devices/${defaultParameters.device}`;
@@ -107,11 +107,11 @@ describe('ListDevicePushNotificationChannelsRequest', () => {
107107
});
108108

109109
describe('query parameters', () => {
110-
it('should include required query parameters for GCM', () => {
110+
it('should include required query parameters for FCM', () => {
111111
const request = new ListDevicePushNotificationChannelsRequest(defaultParameters);
112112
const transportRequest = request.request();
113113

114-
assert.equal(transportRequest.queryParameters?.type, 'gcm');
114+
assert.equal(transportRequest.queryParameters?.type, 'fcm');
115115
assert.equal(transportRequest.queryParameters?.environment, undefined);
116116
assert.equal(transportRequest.queryParameters?.topic, undefined);
117117
assert.equal(transportRequest.queryParameters?.add, undefined);
@@ -281,11 +281,11 @@ describe('ListDevicePushNotificationChannelsRequest', () => {
281281
});
282282

283283
describe('environment defaults', () => {
284-
it('should not set environment for GCM', () => {
284+
it('should not set environment for FCM', () => {
285285
const request = new ListDevicePushNotificationChannelsRequest({
286286
...defaultParameters,
287-
pushGateway: 'gcm',
288-
environment: 'production', // Should be ignored for GCM
287+
pushGateway: 'fcm',
288+
environment: 'production', // Should be ignored for FCM
289289
});
290290
const transportRequest = request.request();
291291

test/unit/push_notification/push_remove_channels.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('RemoveDevicePushNotificationChannelsRequest', () => {
1919

2020
defaultParameters = {
2121
device: 'test_device_id',
22-
pushGateway: 'gcm',
22+
pushGateway: 'fcm',
2323
channels: ['channel1', 'channel2'],
2424
keySet: defaultKeySet,
2525
};
@@ -55,7 +55,7 @@ describe('RemoveDevicePushNotificationChannelsRequest', () => {
5555
...defaultParameters,
5656
pushGateway: undefined,
5757
});
58-
assert.equal(request.validate(), 'Missing GW Type (pushGateway: gcm or apns2)');
58+
assert.equal(request.validate(), 'Missing GW Type (pushGateway: fcm or apns2)');
5959
});
6060

6161
it('should validate APNS2 topic when using apns2', () => {
@@ -114,7 +114,7 @@ describe('RemoveDevicePushNotificationChannelsRequest', () => {
114114
const request = new RemoveDevicePushNotificationChannelsRequest(defaultParameters);
115115
const transportRequest = request.request();
116116

117-
assert.equal(transportRequest.queryParameters?.type, 'gcm');
117+
assert.equal(transportRequest.queryParameters?.type, 'fcm');
118118
assert.equal(transportRequest.queryParameters?.remove, 'channel1,channel2');
119119
assert.equal(transportRequest.queryParameters?.environment, undefined);
120120
assert.equal(transportRequest.queryParameters?.topic, undefined);
@@ -254,7 +254,7 @@ describe('RemoveDevicePushNotificationChannelsRequest', () => {
254254
it('should not set environment for GCM', () => {
255255
const request = new RemoveDevicePushNotificationChannelsRequest({
256256
...defaultParameters,
257-
pushGateway: 'gcm',
257+
pushGateway: 'fcm',
258258
environment: 'production', // Should be ignored for GCM
259259
});
260260
const transportRequest = request.request();

0 commit comments

Comments
 (0)