Skip to content

Instantly share code, notes, and snippets.

@jamesholcomb
Last active January 11, 2017 00:17
Show Gist options
  • Save jamesholcomb/a21cfa3ae34591c7b9c8c468192aead9 to your computer and use it in GitHub Desktop.
Save jamesholcomb/a21cfa3ae34591c7b9c8c468192aead9 to your computer and use it in GitHub Desktop.
APNS auth token push notification test for Node
const PushNotifications = new require('node-pushnotifications')
const bundleId = '<BUNDLE_ID>'
const deviceToken = '<DEVICE_TOKEN>'
const settings = {
apn: {
token: {
"key": './certs/key.p8', // optionally: fs.readFileSync('./certs/key.p8')
"keyId": "<APNS_AUTH_KEY>",
"teamId": "<TEAM_ID>",
"production": false
}
}
}
const push = new PushNotifications(settings)
push.send(deviceToken, {
title: 'Test',
body: 'Test',
topic: bundleId
}).then((result) => {
console.info("Result: ", JSON.stringify((result)))
process.exit(0)
}).catch((err) => {
console.error("Error: ", JSON.stringify(err))
process.exit(-1)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment