-
-
Save smurfpandey/e65fb82da3a31f5683f3 to your computer and use it in GitHub Desktop.
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