Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APNS HTTP (HTTP2) support #157

Closed
TysonAndre opened this issue Jun 16, 2017 · 2 comments
Closed

APNS HTTP (HTTP2) support #157

TysonAndre opened this issue Jun 16, 2017 · 2 comments

Comments

@TysonAndre
Copy link
Contributor

See Apple's documentation at https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html

http://gobiko.com/blog/token-based-authentication-http2-example-apns/ seems like it may help explain high level of setting this up?

Probably implement this with provider certificates if the main use case is self-service, not familiar with the use case for tokens. #149 is related to this.

Miscellaneous notes on how this should be implemented:

  • Apple has guidelines on how individual HTTP2 header names should be encoded. The last time I checked, golang didn't have an API to do that. I'm not sure if it's an issue in practice.
  • encode without escaping unicode, like the binary protocol
  • The api provider abstraction may or may not work (srv/apns/binary_api is one "api" implementing a golang interface, srv/apns/http2_api would be another)
  • Need to investigate if this will significantly change CPU load or network usage.
    For easy migration and testing, one possibility may be to allow adding an option to /push (uniqush.push.protocol=http2) to opt into the HTTP2 api. This gives you accurate results for the push, but increases latency somewhat.
  • Uniqush clients should not notice the effects of this change unless they're configured to, at least not until a major/minor version bump.
    Config file settings can be changed, etc.
  • Need a way to migrating without losing track of subscribers in a service. Unit test this. (See apns-test.sh, which still needs to support binary protocol v2
  • Be careful about connect/send/dns lookup timeouts
  • If you don't receive a response within some time limit (e.g. 1s), send a timeout response to the uniqush client?
  • Can the cert/key be reused from binary clients
  • Bump payload limit to from 2048 to 4096
@TysonAndre
Copy link
Contributor Author

golang/go#15592 - seems like header guidelines aren't important

TysonAndre added a commit that referenced this issue Jul 14, 2017
+ New feature: Add /previewpush endpoint to preview the payload that would be
  generated and sent to push services. (Issue #140)
  This helps with debugging.
+ Maintenance: Update APNS binary provider API(default) from version 1 to version 2.
+ Maintenance: Upgrade to redis.v5 (Issue #143)
+ New provider: Add FCM support. (Issue #148)
  The parameters that would be provided to /addpsp, /subscribe, and /push are
  the same as they would be for GCM. (Replace "fcm" with "gcm")
+ New feature: Add support APNS HTTP2 API (Issue #157, PR #173)
  This gives more accurate results on whether a push succeeded,
  and should not impact Uniqush's performance.
  To set this up, call /addpsp (to create a new provider or modify an
  existing provider) with the same params you would use to create a new
  APNS endpoint for binary providers (including cert and key),
  in addition to providing `bundleid`.
  Currently, to make testing easy, each call to `/push` must be provided with
  the query param value `uniqush.http=1`.
  Otherwise, uniqush continues to use the APNS binary provider API.
+ Maintenance: Use unescaped payloads for GCM and FCM.
  This allows larger payloads, avoiding escaping characters such as `<` and `>`

Fixes #134

go 1.8.3+ and an up to date version of golang.org/x/net/http2
are suggested (For the APNS HTTP2 API).
@TysonAndre
Copy link
Contributor Author

To enable this,

  1. First, you must add bundleid=com.myapp to the query params in a call to /addpsp (Where your app build's bundleid for that environmentis com.myapp).
    (This can be used to modify a pre-existing PSP and keep existing subscriber. You have to provide every single field you used in the previous call to /addpsp, e.g. if it's a sandbox, you have to set sandbox=true)

    If there is no bundle id, then APNs can't accept the push over HTTP2.

  2. set uniqush.http2=1 in the query param in a call to /push to enable it for that push.

    (If the bundle id is somehow different for that app (e.g. build for QAing with a different app), the push will fail)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant