Created
March 30, 2015 22:31
-
-
Save argon/e7cfa80fc709c5e6a515 to your computer and use it in GitHub Desktop.
node-apn benchmark
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 apn = require('apn'); | |
var token = "<token here>"; | |
var service = new apn.connection({ | |
maxConnections: 1 | |
}); | |
service.on("completed", function() { console.log("Completed!")}); | |
service.on("connected", function() { console.log("Connected"); }); | |
service.on('disconnected', function() { console.log("Disconnected", arguments); }); | |
service.on('error', function(err) { console.log("Standard error", err); }); | |
service.on('socketError', function(err) { console.log("Socket error", err.message); }); | |
service.on('timeout', function() { console.log("Timeout"); }); | |
service.on('transmissionError', function(err) { console.log("Transmission Error", err); }); | |
var total = 0; | |
service.on("transmitted", function(notification) { | |
if(total === 0) { | |
console.time("notifications"); | |
} | |
if(total === count - 1) { | |
console.timeEnd("notifications"); | |
} | |
total++; | |
}); | |
var count = 10000; | |
var note = new apn.notification(); | |
for (i=0; i < count; i++) { | |
note.badge = 1; | |
service.pushNotification(note, token); | |
} | |
service.shutdown(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So is it OK to send high volume notifications to a SINGLE REAL device token for testing? and Apple only pushes some of them to the phone? or does the device melts?