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> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user