18 releases

✓ Uses Rust 2018 edition

new 0.5.0-alpha.5 Sep 12, 2019
0.5.0-alpha.3 Sep 8, 2019
0.4.1 Sep 2, 2019
0.4.0 Mar 15, 2019
0.2.3 Jun 2, 2018

#1 in #apple

Download history 13/week @ 2019-05-30 46/week @ 2019-06-06 7/week @ 2019-06-13 49/week @ 2019-06-20 167/week @ 2019-06-27 105/week @ 2019-07-04 226/week @ 2019-07-11 21/week @ 2019-07-18 50/week @ 2019-07-25 31/week @ 2019-08-01 29/week @ 2019-08-08 3/week @ 2019-08-15 96/week @ 2019-08-22 83/week @ 2019-08-29 69/week @ 2019-09-05

312 downloads per month
Used in 1 crate

MIT license

83KB
1.5K SLoC

a2

Travis Build Status MIT licensed crates.io

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

Help needed

The main author is not currently owning any Apple phones, so would be nice to have some help from a co-author with needed devices and an Apple developer account. If you happen to have them and are willing to help, please contact!

Alpha status

The current master and alpha versions use std::future with async/await syntax, and requires a nightly compiler. 0.4 works with stable and futures 0.1.

Bugfixes for the stable release should go against the v0.4 branch.

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.

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 XORC Notifications, which is a full-fledged consumer for sending 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

Contact

oh_lawd @ IRC (Freenode, Mozilla)

Dependencies

~18MB
~418K SLoC