mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
add method to determine which url to use
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user