Pitch
A lightweight, non intrusive, low dependency library to communicate with APNS over HTTP/2 built with Swift NIO.
Motivations
APNS is used to push billions of pushes a day, (7 billion per day in 2012). Many of us using Swift on the backend are using it to power our iOS applications. Having a community supported APNS implementation would go a long way to making it the fastest, free-ist, and simplest solution that exists.
Also too many non standard approaches currently exist. Some use code that depends on Security (Doesn't work on linux) and I haven't found one that uses NIO with no other dependencies. Some just execute curl commands.
Existing solutions
- https://github.com/moritzsternemann/nio-apns
- https://github.com/kaunteya/APNSwift
- Supporting Push Notifications with Vapor 3 | by Nathan Tannar | Medium
- https://github.com/PerfectlySoft/Perfect-Notifications
- https://github.com/hjuraev/VaporNotifications
Almost all require a ton of dependencies.
Proposed Solution
Develop a Swift NIO HTTP2 solution with minimal dependencies.
A proof of concept implementation exists here
What it does do
- Provides an API for handling connection to Apples HTTP2 APNS server
- Provides proper error messages that APNS might respond with.
- Uses custom/non dependency implementations of JSON Web Token specific to APNS (using rfc7519
- Imports OpenSSL for SHA256 and ES256
- Provides an interface for signing your Push Notifications
- Signs your token request
- Sends push notifications to a specific device.
- Adheres to guidelines Apple Provides.
What it doesn't do YET
- Use an OpenSSL implementation that is not
CNIOOpenSSL
What it won't do.
- Store/register device tokens
- Build an HTTP2 generic client
- Google Cloud Message
- Refresh your token no more than once every 20 minutes and no less than once every 60 minutes. (up to connection handler)
- Provide multiple device tokens to send same push to.
What it could do
- Use the SSWG HTTP2 client
- Be the APNS library for all of Server Side Swift projects!
Please let me know what y'all think. I’ll edit the topic with feedback as it comes in!