diff --git a/src/services/NotificationService.ts b/src/services/NotificationService.ts index 7953d91..3ee05b5 100644 --- a/src/services/NotificationService.ts +++ b/src/services/NotificationService.ts @@ -155,9 +155,9 @@ export class NotificationService { const devBaseUrl = "https://api.development.push.apple.com" const prodBaseUrl = "https://api.push.apple.com" - let hostToUse = prodBaseUrl; - if (process.env.NODE_ENV !== "production") { - hostToUse = devBaseUrl; + let hostToUse = devBaseUrl; + if (process.env.APNS_IS_PRODUCTION === "1") { + hostToUse = prodBaseUrl; } const path = "/3/device/" + deviceId; diff --git a/test/services/NotificationServiceTests.test.ts b/test/services/NotificationServiceTests.test.ts index a3ec0fc..7f3cfcf 100644 --- a/test/services/NotificationServiceTests.test.ts +++ b/test/services/NotificationServiceTests.test.ts @@ -189,8 +189,8 @@ describe("NotificationService", () => { }); describe('getAPNsFullUrlToUse', () => { - it('should return the production URL when NODE_ENV is set to "production"', () => { - process.env.NODE_ENV = 'production'; + it('should return the production URL when APNS_IS_PRODUCTION is set to "1"', () => { + process.env.APNS_IS_PRODUCTION = "1"; const deviceId = 'testDeviceId'; const result = NotificationService.getAPNsFullUrlToUse(deviceId); @@ -200,8 +200,8 @@ describe("NotificationService", () => { expect(path).toBe(`/3/device/${deviceId}`); }); - it('should return the sandbox URL when NODE_ENV is not set to "production"', () => { - process.env.NODE_ENV = 'development'; + it('should return the sandbox URL when APNS_IS_PRODUCTION is set to something other than 1', () => { + process.env.APNS_IS_PRODUCTION = "0"; const deviceId = 'testDeviceId'; const result = NotificationService.getAPNsFullUrlToUse(deviceId);