GithubHelp home page GithubHelp logo

s-fabian / a2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from walletconnect/a2

0.0 0.0 0.0 249 KB

An Asynchronous Apple Push Notification (apns2) Client for Rust

License: MIT License

Rust 99.86% Nix 0.14%

a2's Introduction

a2

CI Status MIT licensed crates.io

HTTP/2 Apple Push Notification Service for Rust using Tokio and async sending.

Requirements

Needs a Tokio executor version 1.0 or later and Rust compiler version 1.60.0 or later.

Documentation

Features

  • Fast asynchronous sending, based on h2 and hyper crates.
  • Payload serialization/deserialization with serde.
  • Provides a type-safe way of constructing different types of payloads. Custom data through Serialize, allowing use of structs or dynamic hashmaps.
  • Supports .p12 certificate databases to connect using a custom certificate.
  • Supports .p8 private keys to connect using authentication tokens.
  • If using authentication tokens, handles signature renewing for Apple's guidelines and caching for maximum performance.
  • Cryptography primitives are provided either by openssl or ring.

Examples

The library supports connecting to Apple Push Notification service either using a certificate with a password or a private key with a team id and key id. Both are available from your Apple account and with both it is possible to send push notifications to one application.

To see it used in a real project, take a look to the Echo Server, which is a project by WalletConnect to handle incoming webhooks and converting them to push notifications.

Gotchas

We've been pushing some millions of notifications daily through this library and are quite happy with it. Some things to know, if you're evaluating the library for production use:

  • Do not open new connections for every request. Apple will treat it as Denial of Service attack and block the sending IP address. When using the same Client for multiple requests, the Client keeps the connection alive if pushing steady traffic through it.

  • For one app, one connection is quite enough already for certain kind of loads. With http2 protocol, the events are asynchronous and the pipeline can hold several outgoing requests at the same time. The biggest reason to open several connections is for redundancy, running your sender service on different machines.

  • It seems to be Apple doesn't like when sending tons of notifications with faulty device tokens and it might lead to ConnectionErrors. Do not send more notifications with tokens that return Unregistered, BadDeviceToken or DeviceTokenNotForTopic.

Tests

cargo test

a2's People

Contributors

pimeys avatar polyitan avatar harryet avatar sorccu avatar azuremarker avatar jrconlin avatar dbrgn avatar pheki avatar ajevans99 avatar s-fabian avatar hortopan avatar jacobh avatar janc avatar jonas-schievink avatar mstrodl avatar rakowskiii avatar rneswold avatar github-actions[bot] avatar

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.