Created
April 17, 2012 17:14
-
-
Save charlesdaniel/2407583 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 apns = require('./node_modules/apn'); | |
var options = { //This is a real prod cert | |
cert: 'cert.pem', // valid cert | |
key: 'key.pem', // valid key | |
gateway: 'gateway.push.apple.com', | |
port: 2195, | |
enhanced: true, | |
cacheLength: 5, | |
errorCallback: function(err, notification) { console.log(" ERROR FROM CALLBACK : ", err, "NOTIFICATION ", notification); }, | |
}; | |
var conn = new apns.connection(options); | |
var tok = // ENTER A REAL TOKEN | |
var tok2 = // ENTER A BAD TOKEN (ie. tok - 1 character) | |
var i = 0; | |
var tm = setInterval(function() { | |
if(i > 100) { clearInterval(tm); } | |
var t = (i % 10 == 0) ? tok : tok2; | |
var dev = new apns.device(t, true); | |
var note = new apns.notification(); | |
note.badge = 0; | |
note.sound = 'default'; | |
note.alert = ' Message #'+i; | |
note.payload ={ | |
m: 'Message #' + i, | |
aps: | |
{ badge: 0, | |
sound: 'default', | |
alert: 'Message #' + i | |
} }; | |
note.device = dev; | |
console.log('pushing ', i); | |
var x = conn.sendNotification(note); | |
console.log("X = ", x); | |
i++; | |
}, 100); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment