add method to determine which url to use

This commit is contained in:
2025-02-03 22:03:28 -08:00
parent 18402401e3
commit f602aa6c2c

View File

@@ -67,16 +67,29 @@ export class NotificationService {
private async sendEtaNotificationImmediately({ deviceId, shuttleId, stopId }: ScheduledNotificationData): Promise<boolean> { private async sendEtaNotificationImmediately({ deviceId, shuttleId, stopId }: ScheduledNotificationData): Promise<boolean> {
this.reloadAPNsTokenIfTimePassed(); this.reloadAPNsTokenIfTimePassed();
const url = this.getAPNsFullUrlToUse(deviceId);
// Construct the fetch request
// Send the fetch request // Send the fetch request
// Check whether it was successful // Check whether it was successful
// Return the result // Return the result
return false; 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) { private async etaSubscriberCallback(eta: IEta) {
const tuple = new TupleKey(eta.shuttleId, eta.stopId); const tuple = new TupleKey(eta.shuttleId, eta.stopId);
// TODO: move device IDs object (with TupleKey based string) to its own class // TODO: move device IDs object (with TupleKey based string) to its own class