From f602aa6c2ca9f0fe314fd308f836b10534e7948f Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 3 Feb 2025 22:03:28 -0800 Subject: [PATCH] add method to determine which url to use --- src/services/NotificationService.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/services/NotificationService.ts b/src/services/NotificationService.ts index ffa0937..40e0dab 100644 --- a/src/services/NotificationService.ts +++ b/src/services/NotificationService.ts @@ -67,16 +67,29 @@ export class NotificationService { private async sendEtaNotificationImmediately({ deviceId, shuttleId, stopId }: ScheduledNotificationData): Promise { this.reloadAPNsTokenIfTimePassed(); - - // Construct the fetch request + const url = this.getAPNsFullUrlToUse(deviceId); // Send the fetch request + // Check whether it was successful // Return the result return false; } + private getAPNsFullUrlToUse(deviceId: string) { + // Construct the fetch request + const devBaseUrl = "https://api.sandbox.push.apple.com" + const prodBaseUrl = "https://api.push.apple.com" + const path = "/3/device/" + deviceId; + + let urlToUse = prodBaseUrl; + if (process.env.NODE_ENV !== "production") { + urlToUse = devBaseUrl + path; + } + return urlToUse; + } + private async etaSubscriberCallback(eta: IEta) { const tuple = new TupleKey(eta.shuttleId, eta.stopId); // TODO: move device IDs object (with TupleKey based string) to its own class