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');