Skip to content

Instantly share code, notes, and snippets.

@fedejordan
Last active January 4, 2021 08:42
Show Gist options
  • Save fedejordan/89cb4fd33a57d18441469748255b1ec6 to your computer and use it in GitHub Desktop.
Save fedejordan/89cb4fd33a57d18441469748255b1ec6 to your computer and use it in GitHub Desktop.
Blog09 - Node.js script to send APN
var deviceToken = '<device-token>';
var apn = require('apn');
var join = require('path').join,
pfx = join(__dirname, '/simplertapp-certificates.p12');
var options = {
pfx: pfx,
passphrase: '<p12-password>',
production: false
};
var apnProvider = new apn.Provider(options);
let notification = new apn.Notification();
notification.alert = "¡Hola, soy una push notification";
apnProvider.send(notification, [deviceToken]).then( (response) => {
process.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment