Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sendAPN(regIds, data) {
const message = new apn.Notification({
retryLimit: data.retries || -1,
expiry: extractExpiry(data),
priority: data.priority === 'normal' ? 5 : 10,
encoding: data.encoding,
payload: data.custom || {},
badge: data.badge,
sound: data.sound,
alert: data.alert || {
title: data.title,
body: data.body,
'title-loc-key': data.titleLocKey,
'title-loc-args': data.titleLocArgs,
'loc-key': data.locKey,
// bodyLocArgs is kept for backward compatibility
'loc-args': data.locArgs || data.bodyLocArgs,
'launch-image': data.launchImage,
static _createProvider(apnsArgs) {
// if using certificate, then topic must be defined
if (!APNS._validateAPNArgs(apnsArgs)) {
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED, 'topic is mssing for %j', apnsArgs);
}
let provider = new apn.Provider(apnsArgs);
// Sets the topic on this provider
provider.topic = apnsArgs.topic;
// Set the priority of the providers, prod cert has higher priority
if (apnsArgs.production) {
provider.priority = 0;
} else {
provider.priority = 1;
}
return provider;
}
static _generateNotification(coreData, headers) {
let notification = new apn.Notification();
let payload = {};
for (let key in coreData) {
switch (key) {
case 'aps':
notification.aps = coreData.aps;
break;
case 'alert':
notification.setAlert(coreData.alert);
break;
case 'title':
notification.setTitle(coreData.title);
break;
case 'badge':
notification.setBadge(coreData.badge);
break;
case 'sound':
constructor(settings) {
try {
this.connection = new apn.Provider(settings);
} catch (e) {
this.connectionError = e;
this.connection = null;
}
}