Giter Club home page Giter Club logo

Comments (2)

TysonAndre avatar TysonAndre commented on May 26, 2024

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/ mentions the following for Best Practices While Connecting to APNs

  • Depending on throughput and request-response turnaround time, open new connections.
  • Avoid push burst over selective connections. Diversifying push traffic over many connections distributes push traffic for your application across all APNs servers.

from node-apn.

eladnava avatar eladnava commented on May 26, 2024

That's awesome.

For the time being (until this is merged), I am replicating this behavior by creating multiple apn.Provider instances and iterating them in a round-robin style:

// Create a pool of providers (multiple connections)
var apnsProviders = [], providerCount = 50, currentProvider = 0;

// Create providers
for (var i = 0; i < providerCount; i++) {
    // Set up apn with the APNs Auth Key
    apnsProviders.push(new apn.Provider({
        token: config.apns,
        production: process.platform == 'darwin'
    }));
}

And in the notification sending section:

    // Actually send the notification
    apnsProviders[currentProvider].send(notification, token).then((result) => {
        // console.log(result);
        if (doneCallback) {
            doneCallback();
        }
    })

    // Increment provider
    currentProvider++;

    // End of the provider list?
    if (currentProvider >= apnsProviders.length) {
        currentProvider = 0;
    }

from node-apn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.