Skip to content

Instantly share code, notes, and snippets.

@argon
Created March 30, 2015 22:31
Show Gist options
  • Save argon/e7cfa80fc709c5e6a515 to your computer and use it in GitHub Desktop.
Save argon/e7cfa80fc709c5e6a515 to your computer and use it in GitHub Desktop.
node-apn benchmark
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();
@behrad
Copy link

behrad commented Feb 11, 2016

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment