diff --git a/src/services/NotificationService.ts b/src/services/NotificationService.ts index a223e89..ffa0937 100644 --- a/src/services/NotificationService.ts +++ b/src/services/NotificationService.ts @@ -12,7 +12,7 @@ interface ScheduledNotificationData { } export class NotificationService { - private token: string | undefined = undefined; + private apnsToken: string | undefined = undefined; private _lastRefreshedTimeMs: number | undefined = undefined; get lastRefreshedTimeMs() { @@ -53,7 +53,7 @@ export class NotificationService { "iat": now, }; - this.token = jwt.sign(claimsPayload, privateKey, { + this.apnsToken = jwt.sign(claimsPayload, privateKey, { algorithm: "ES256", header: tokenHeader }); @@ -66,6 +66,8 @@ export class NotificationService { } private async sendEtaNotificationImmediately({ deviceId, shuttleId, stopId }: ScheduledNotificationData): Promise { + this.reloadAPNsTokenIfTimePassed(); + // Construct the fetch request // Send the fetch request