From a880d71c87c05285f1aad1f168334596459fb3a6 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 10 Feb 2025 13:34:48 -0800 Subject: [PATCH] use updated getAPNs... method --- src/services/NotificationService.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/NotificationService.ts b/src/services/NotificationService.ts index d21726a..1f52eef 100644 --- a/src/services/NotificationService.ts +++ b/src/services/NotificationService.ts @@ -82,7 +82,6 @@ export class NotificationService { private async sendEtaNotificationImmediately(notificationData: ScheduledNotificationData): Promise { const { deviceId, shuttleId, stopId } = notificationData; this.reloadAPNsTokenIfTimePassed(); - const url = NotificationService.getAPNsFullUrlToUse(deviceId); const shuttle = await this.repository.getShuttleById(shuttleId); const stop = await this.repository.getStopById(stopId); @@ -109,9 +108,11 @@ export class NotificationService { throw new Error("APNS_BUNDLE_ID environment variable is not set correctly"); } + const { path, host } = NotificationService.getAPNsFullUrlToUse(deviceId); + const headers = { ':method': 'POST', - ':path': `/3/device/${deviceId}`, + ':path': path, 'authorization': `bearer ${this.apnsToken}`, "apns-push-type": "alert", "apns-expiration": "0", @@ -119,7 +120,7 @@ export class NotificationService { "apns-topic": bundleId, }; try { - const client = http2.connect('https://api.development.push.apple.com'); + const client = http2.connect(host); const req = client.request(headers); req.setEncoding('utf8');