Last active
January 4, 2021 08:42
-
-
Save fedejordan/89cb4fd33a57d18441469748255b1ec6 to your computer and use it in GitHub Desktop.
Blog09 - Node.js script to send APN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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