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