mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
use updated getAPNs... method
This commit is contained in:
@@ -82,7 +82,6 @@ export class NotificationService {
|
|||||||
private async sendEtaNotificationImmediately(notificationData: ScheduledNotificationData): Promise<boolean> {
|
private async sendEtaNotificationImmediately(notificationData: ScheduledNotificationData): Promise<boolean> {
|
||||||
const { deviceId, shuttleId, stopId } = notificationData;
|
const { deviceId, shuttleId, stopId } = notificationData;
|
||||||
this.reloadAPNsTokenIfTimePassed();
|
this.reloadAPNsTokenIfTimePassed();
|
||||||
const url = NotificationService.getAPNsFullUrlToUse(deviceId);
|
|
||||||
|
|
||||||
const shuttle = await this.repository.getShuttleById(shuttleId);
|
const shuttle = await this.repository.getShuttleById(shuttleId);
|
||||||
const stop = await this.repository.getStopById(stopId);
|
const stop = await this.repository.getStopById(stopId);
|
||||||
@@ -109,9 +108,11 @@ export class NotificationService {
|
|||||||
throw new Error("APNS_BUNDLE_ID environment variable is not set correctly");
|
throw new Error("APNS_BUNDLE_ID environment variable is not set correctly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { path, host } = NotificationService.getAPNsFullUrlToUse(deviceId);
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
':method': 'POST',
|
':method': 'POST',
|
||||||
':path': `/3/device/${deviceId}`,
|
':path': path,
|
||||||
'authorization': `bearer ${this.apnsToken}`,
|
'authorization': `bearer ${this.apnsToken}`,
|
||||||
"apns-push-type": "alert",
|
"apns-push-type": "alert",
|
||||||
"apns-expiration": "0",
|
"apns-expiration": "0",
|
||||||
@@ -119,7 +120,7 @@ export class NotificationService {
|
|||||||
"apns-topic": bundleId,
|
"apns-topic": bundleId,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const client = http2.connect('https://api.development.push.apple.com');
|
const client = http2.connect(host);
|
||||||
const req = client.request(headers);
|
const req = client.request(headers);
|
||||||
req.setEncoding('utf8');
|
req.setEncoding('utf8');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user