update tests and implementation ofr getAPNsFullUrlToUse

This commit is contained in:
2025-02-10 13:30:29 -08:00
parent da224c36ed
commit baa94eeef5
2 changed files with 28 additions and 13 deletions

View File

@@ -11,6 +11,12 @@ export interface ScheduledNotificationData {
stopId: string;
}
interface APNsUrl {
fullUrl: string;
path: string;
host: string;
}
export class NotificationService {
public readonly secondsThresholdForNotificationToFire = 300;
@@ -162,17 +168,25 @@ export class NotificationService {
}
}
public static getAPNsFullUrlToUse(deviceId: string) {
public static getAPNsFullUrlToUse(deviceId: string): APNsUrl {
// Construct the fetch request
const devBaseUrl = "https://api.development.push.apple.com"
const prodBaseUrl = "https://api.push.apple.com"
const path = "/3/device/" + deviceId;
let urlToUse = prodBaseUrl + path;
let hostToUse = prodBaseUrl;
if (process.env.NODE_ENV !== "production") {
urlToUse = devBaseUrl + path;
hostToUse = devBaseUrl;
}
return urlToUse;
const path = "/3/device/" + deviceId;
const fullUrl = hostToUse + path;
const constructedObject = {
fullUrl,
host: hostToUse,
path,
}
return constructedObject;
}
private async etaSubscriberCallback(eta: IEta) {