
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
push-notification
Advanced tools
push notification for apple push notification (APN) and google cloud messaging (GCM)
$ npm install --save push-notification
const PushNotification = require('push-notification');
const DeviceType = PushNotification.DeviceType;
const pn = PushNotification({
apn: {
cert: path.resolve('./cert/cert.pem'),
key: path.resolve('./cert/key.pem'),
production: false,
},
gcm: {
apiKey: 'gcm-api-key'
}
});
const data = {
title: 'Title',
message: 'Message',
badge: '',
sound: '',
payload: {
param1: 'additional data',
param2: 'another data'
}
};
pn.pushToAPN('ios-device-token', data); // push to single ios device
pn.pushToAPN(['token1', 'token2', 'token3'], data); // push to multiple ios devices
pn.push('device-token', data, DeviceType.IOS); // push to single ios device
pn.push(['token1', 'token2', 'token3'], data, DeviceType.IOS); // push to multiple ios devices
pn.pushToGCM('android-device-token', data); // push to single android device
pn.pushToGCM(['token1', 'token2', 'token3'], data); // push to multiple android devices
pn.push('device-token', data, DeviceType.ANDROID); // push to single android device
pn.push(['token1', 'token2', 'token3'], data, DeviceType.ANDROID); // push to multiple android devices
const devices = [
{ token: 'token1', type: DeviceType.IOS },
{ token: 'token2', type: DeviceType.ANDROID }
];
// send notification to all devices
Promise.all(devices.map(device => pn.push(device.token, data, device.type)));
// or this might be more performant
const iosTokens = devices.filter(d => d.type === DeviceType.IOS).map(d => d.token);
const andTokens = devices.filter(d => d.type === DeviceType.ANDROID).map(d => d.token);
Promise.all([
iosTokens.length ? pn.push(iosTokens, data, DeviceType.IOS) : Promise.resolve(),
andTokens.length ? pn.push(andTokens, data, DeviceType.ANDROID) : Promise.resolve()
]);
push, pushToAPN, pushToGCM return Promise instance
pn.push(...).then(res => console.log(res)).catch(err => console.log(err));
options
tokens
data
Promise resolves push result
tokens
data
Promise resolves push result
tokens
data
type
Promise resolves push result
MIT © Dongwon Lim
FAQs
push notification for apple push notification (APN) and google cloud messaging (GCM)
We found that push-notification demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.