diff --git a/lib/push-notifications.js b/lib/push-notifications.js index d6664cf..856633f 100644 --- a/lib/push-notifications.js +++ b/lib/push-notifications.js @@ -1,7 +1,5 @@ "use strict"; -var _sendGCM = _interopRequireDefault(require("./sendGCM")); - var _sendAPN = _interopRequireDefault(require("./sendAPN")); var _sendFCM = _interopRequireDefault(require("./sendFCM")); @@ -25,7 +23,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope class PN { constructor(options) { this.setOptions(options); - this.useFcmOrGcmMethod = this.settings.isLegacyGCM ? _constants.GCM_METHOD : _constants.FCM_METHOD; + this.useFcmOrGcmMethod = _constants.FCM_METHOD; } setOptions(opts) { @@ -108,7 +106,6 @@ class PN { send(_regIds, data, callback) { const promises = []; - const regIdsGCM = []; const regIdsFCM = []; const regIdsAPN = []; const regIdsWNS = []; @@ -124,8 +121,6 @@ class PN { if (pushMethod === _constants.WEB_METHOD) { regIdsWebPush.push(regId); - } else if (pushMethod === _constants.GCM_METHOD) { - regIdsGCM.push(regId); } else if (pushMethod === _constants.FCM_METHOD) { regIdsFCM.push(regId); } else if (pushMethod === _constants.WNS_METHOD) { @@ -140,12 +135,6 @@ class PN { }); try { - // Android GCM / FCM (Android/iOS) Legacy - if (regIdsGCM.length > 0) { - promises.push(this.sendWith(_sendGCM.default, regIdsGCM, data)); - } // FCM (Android/iOS) - - if (regIdsFCM.length > 0) { promises.push(this.sendWith(_sendFCM.default, regIdsFCM, data)); } // iOS APN @@ -219,6 +208,5 @@ module.exports = PN; module.exports.WEB = _constants.WEB_METHOD; module.exports.WNS = _constants.WNS_METHOD; module.exports.ADM = _constants.ADM_METHOD; -module.exports.GCM = _constants.GCM_METHOD; module.exports.FCM = _constants.FCM_METHOD; module.exports.APN = _constants.APN_METHOD; \ No newline at end of file diff --git a/src/push-notifications.js b/src/push-notifications.js index 5ec49e6..1687973 100644 --- a/src/push-notifications.js +++ b/src/push-notifications.js @@ -1,6 +1,5 @@ /* eslint-disable import/no-import-module-exports */ -import sendGCM from './sendGCM'; import APN from './sendAPN'; import sendFCM from './sendFCM'; import sendADM from './sendADM'; @@ -13,7 +12,6 @@ import { WEB_METHOD, WNS_METHOD, ADM_METHOD, - GCM_METHOD, APN_METHOD, FCM_METHOD, } from './constants'; @@ -21,9 +19,7 @@ import { class PN { constructor(options) { this.setOptions(options); - this.useFcmOrGcmMethod = this.settings.isLegacyGCM - ? GCM_METHOD - : FCM_METHOD; + this.useFcmOrGcmMethod = FCM_METHOD; } setOptions(opts) { @@ -90,7 +86,6 @@ class PN { send(_regIds, data, callback) { const promises = []; - const regIdsGCM = []; const regIdsFCM = []; const regIdsAPN = []; const regIdsWNS = []; @@ -105,8 +100,6 @@ class PN { if (pushMethod === WEB_METHOD) { regIdsWebPush.push(regId); - } else if (pushMethod === GCM_METHOD) { - regIdsGCM.push(regId); } else if (pushMethod === FCM_METHOD) { regIdsFCM.push(regId); } else if (pushMethod === WNS_METHOD) { @@ -121,11 +114,6 @@ class PN { }); try { - // Android GCM / FCM (Android/iOS) Legacy - if (regIdsGCM.length > 0) { - promises.push(this.sendWith(sendGCM, regIdsGCM, data)); - } - // FCM (Android/iOS) if (regIdsFCM.length > 0) { promises.push(this.sendWith(sendFCM, regIdsFCM, data)); @@ -203,6 +191,5 @@ module.exports = PN; module.exports.WEB = WEB_METHOD; module.exports.WNS = WNS_METHOD; module.exports.ADM = ADM_METHOD; -module.exports.GCM = GCM_METHOD; module.exports.FCM = FCM_METHOD; module.exports.APN = APN_METHOD; diff --git a/src/utils/tools.js b/src/utils/tools.js index 4ea4fec..095ca96 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -75,30 +75,6 @@ const containsValidRecipients = R.either( const propValueToSingletonArray = (propName) => R.compose(R.of, R.prop(propName)); -const buildGcmNotification = (data) => { - const notification = data.fcm_notification || { - title: data.title, - body: data.body, - icon: data.icon, - image: data.image, - picture: data.picture, - style: data.style, - sound: data.sound, - badge: data.badge, - tag: data.tag, - color: data.color, - click_action: data.clickAction || data.category, - body_loc_key: data.locKey, - body_loc_args: toJSONorUndefined(data.locArgs), - title_loc_key: data.titleLocKey, - title_loc_args: toJSONorUndefined(data.titleLocArgs), - android_channel_id: data.android_channel_id, - notification_count: data.notificationCount || data.badge, - }; - - return notification; -}; - const buildApnsMessage = (data) => { const message = new ApnsMessage({ retryLimit: data.retries || -1, diff --git a/test/push-notifications/regIds.js b/test/push-notifications/regIds.js index 556d0a1..443a67e 100644 --- a/test/push-notifications/regIds.js +++ b/test/push-notifications/regIds.js @@ -3,7 +3,6 @@ import { expect } from 'chai'; // eslint-disable-line import/no-extraneous-dependencies import sinon from 'sinon'; // eslint-disable-line import/no-extraneous-dependencies import PN from '../../src'; -import sendGCM from '../../src/sendGCM'; import sendADM from '../../src/sendADM'; import sendWNS from '../../src/sendWNS'; import sendWeb from '../../src/sendWeb'; @@ -53,7 +52,6 @@ describe('push-notifications: call with registration ids for android, ios, windo case 0: case 1: case 2: - expect(method).to.equal(sendGCM); break; case 3: diff --git a/test/send/sendADM.js b/test/send/sendADM.js index f05ac31..c98cea4 100644 --- a/test/send/sendADM.js +++ b/test/send/sendADM.js @@ -3,12 +3,7 @@ import { expect } from 'chai'; import sinon from 'sinon'; import adm from 'node-adm'; import PN from '../../src'; -import { - sendOkMethodGCM, - testPushSuccess, - testPushError, - testPushException, -} from '../util'; +import { testPushSuccess, testPushError, testPushException } from '../util'; const method = 'adm'; const regIds = [ @@ -34,7 +29,6 @@ const pn = new PN(admOpts); const fErr = new Error('Forced error'); const testSuccess = testPushSuccess(method, regIds); -const testSuccessGCM = testPushSuccess('gcm', regIds); const testError = testPushError(method, regIds, fErr.message); const testException = testPushException(fErr.message); @@ -164,31 +158,4 @@ describe('push-notifications-adm', () => { .catch((err) => testException(err, undefined, done)); }); }); - - describe('send push notifications using FCM', () => { - const pnGCM = new PN({ - isAlwaysUseFCM: true, - isLegacyGCM: true, - }); - before(() => { - sendMethod = sendOkMethodGCM(regIds, data); - }); - - after(() => { - sendMethod.restore(); - }); - - it('all responses should be successful (callback)', (done) => { - pnGCM.send(regIds, data, (err, results) => - testSuccessGCM(err, results, done) - ); - }); - - it('all responses should be successful (promise)', (done) => { - pnGCM - .send(regIds, data) - .then((results) => testSuccessGCM(null, results, done)) - .catch(done); - }); - }); }); diff --git a/test/send/sendAPN.js b/test/send/sendAPN.js index 7df440b..52f9e20 100644 --- a/test/send/sendAPN.js +++ b/test/send/sendAPN.js @@ -9,12 +9,7 @@ import { readFileSync } from 'fs'; import apn from '@parse/node-apn'; import PN from '../../src'; import APN from '../../src/sendAPN'; -import { - sendOkMethodGCM, - testPushSuccess, - testPushError, - testPushException, -} from '../util'; +import { testPushSuccess, testPushError, testPushException } from '../util'; const { expect } = chai; chai.use(dirtyChai); @@ -47,7 +42,6 @@ const fErr = new Error('Forced error'); const errStatusCode = '410'; const testSuccess = testPushSuccess(method, regIds); -const testSuccessGCM = testPushSuccess('gcm', regIds); const testError = testPushError(method, regIds, fErr.message); const testErrorStatusCode = testPushError(method, regIds, errStatusCode); const testException = testPushException(fErr.message); @@ -756,31 +750,4 @@ describe('push-notifications-apn', () => { }); }); }); - - describe('send push notifications successfully using FCM', () => { - const pnGCM = new PN({ - isAlwaysUseFCM: true, - isLegacyGCM: true, - }); - before(() => { - sendMethod = sendOkMethodGCM(regIds, data); - }); - - after(() => { - sendMethod.restore(); - }); - - it('all responses should be successful (callback)', (done) => { - pnGCM.send(regIds, data, (err, results) => - testSuccessGCM(err, results, done) - ); - }); - - it('all responses should be successful (promise)', (done) => { - pnGCM - .send(regIds, data) - .then((results) => testSuccessGCM(null, results, done)) - .catch(done); - }); - }); }); diff --git a/test/send/sendWNS-accessToken.js b/test/send/sendWNS-accessToken.js index 19acea3..8e40fa9 100644 --- a/test/send/sendWNS-accessToken.js +++ b/test/send/sendWNS-accessToken.js @@ -3,12 +3,7 @@ import { expect } from 'chai'; import sinon from 'sinon'; import wns from 'wns'; import PN from '../../src'; -import { - sendOkMethodGCM, - testPushSuccess, - testPushError, - testPushException, -} from '../util'; +import { testPushSuccess, testPushError, testPushException } from '../util'; const method = 'wns'; const regIds = [ @@ -92,7 +87,6 @@ const sendWNS = { }; const testSuccess = testPushSuccess(method, regIds); -const testSuccessGCM = testPushSuccess('gcm', regIds); const testError = testPushError(method, regIds, fErr.message); const testException = testPushException(fErr.message); @@ -223,31 +217,4 @@ describe('push-notifications-wns-access-token', () => { .catch((err) => testException(err, undefined, done)); }); }); - - describe('send push notifications successfully using FCM', () => { - const pnGCM = new PN({ - isAlwaysUseFCM: true, - isLegacyGCM: true, - }); - before(() => { - sendMethod = sendOkMethodGCM(regIds, data); - }); - - after(() => { - sendMethod.restore(); - }); - - it('all responses should be successful (callback)', (done) => { - pnGCM.send(regIds, data, (err, results) => - testSuccessGCM(err, results, done) - ); - }); - - it('all responses should be successful (promise)', (done) => { - pnGCM - .send(regIds, data) - .then((results) => testSuccessGCM(null, results, done)) - .catch(done); - }); - }); }); diff --git a/test/send/sendWNS.js b/test/send/sendWNS.js index 6ab4a46..fdda160 100644 --- a/test/send/sendWNS.js +++ b/test/send/sendWNS.js @@ -3,12 +3,7 @@ import { expect } from 'chai'; import sinon from 'sinon'; import wns from 'wns'; import PN from '../../src'; -import { - sendOkMethodGCM, - testPushSuccess, - testPushError, - testPushException, -} from '../util'; +import { testPushSuccess, testPushError, testPushException } from '../util'; const method = 'wns'; const regIds = [ @@ -87,7 +82,6 @@ const sendWNS = { }; const testSuccess = testPushSuccess(method, regIds); -const testSuccessGCM = testPushSuccess('gcm', regIds); const testError = testPushError(method, regIds, fErr.message); const testException = testPushException(fErr.message); @@ -260,31 +254,4 @@ describe('push-notifications-wns', () => { .catch((err) => testException(err, undefined, done)); }); }); - - describe('send push notifications successfully using FCM', () => { - const pnGCM = new PN({ - isAlwaysUseFCM: true, - isLegacyGCM: true, - }); - before(() => { - sendMethod = sendOkMethodGCM(regIds, data); - }); - - after(() => { - sendMethod.restore(); - }); - - it('all responses should be successful (callback)', (done) => { - pnGCM.send(regIds, data, (err, results) => - testSuccessGCM(err, results, done) - ); - }); - - it('all responses should be successful (promise)', (done) => { - pnGCM - .send(regIds, data) - .then((results) => testSuccessGCM(null, results, done)) - .catch(done); - }); - }); }); diff --git a/test/util.js b/test/util.js index 675974d..8d12e68 100644 --- a/test/util.js +++ b/test/util.js @@ -1,4 +1,3 @@ -import sinon from 'sinon'; import { expect } from 'chai'; export const testPushSuccess = (method, regIds) => (err, results, done) => {