Skip to content

Commit

Permalink
fix: Update APN service to support storage notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jzunigax2 committed Sep 9, 2024
1 parent 5fa70bb commit 0240d28
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/externals/apn/apn.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export class ApnService {
return client;
}

async sendNotification(deviceToken: string, payload: ApnAlert) {
async sendNotification(
deviceToken: string,
payload: ApnAlert,
userUuid?: string,
isStorageNotification = false,
) {
return new Promise((resolve, reject) => {
if (!this.client || this.client.closed) {
this.client = this.connectToAPN();
Expand All @@ -99,13 +104,23 @@ export class ApnService {

req.setEncoding('utf8');

req.write(
JSON.stringify({
aps: {
alert: this.generateAlertBody(payload),
},
}),
);
if (isStorageNotification && userUuid) {
req.write(
JSON.stringify({
'container-identifier':
'NSFileProviderWorkingSetContainerItemIdentifier',
domain: userUuid,
}),
);
} else {
req.write(
JSON.stringify({
aps: {
alert: this.generateAlertBody(payload),
},
}),
);
}

req.end();

Expand Down

0 comments on commit 0240d28

Please sign in to comment.