Last active
January 11, 2017 00:17
-
-
Save jamesholcomb/a21cfa3ae34591c7b9c8c468192aead9 to your computer and use it in GitHub Desktop.
APNS auth token push notification test for Node
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
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