krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

spikes/apns-worker/README.org

04b2b1d914788057bcd20945b876847386eb8f65
moonrise/spikes/apns-worker/README.org rendered · source · history · blame · raw

34 lines · 1066 bytes

3 symbols in this file
 1#+title: apns-worker spike
 2
 3Checks that a deployed Cloudflare Worker can send APNs pushes. APNs only
 4speaks HTTP/2; =wrangler dev= does not (workerd issue #4841), so test
 5deployed.
 6
 7* probe (no Apple credentials)
 8#+begin_src sh
 9wrangler deploy
10curl https://moonrise-apns-spike.<subdomain>.workers.dev/probe
11#+end_src
12
13Sends from a throwaway key to a dummy token on the sandbox host. Any APNs
14JSON reason (expected: 403 =InvalidProviderToken=) means the HTTP/2
15connection worked. A network error means it did not.
16
17* real push
18Needs an APNs auth key (.p8), its key ID, the team ID, the app's bundle ID,
19and a sandbox device token from a development build.
20
21#+begin_src sh
22# set APNS_KEY_ID, APNS_TEAM_ID, APNS_TOPIC in wrangler.jsonc
23wrangler secret put APNS_KEY < AuthKey_XXXXXXXXXX.p8
24wrangler secret put SPIKE_SECRET
25wrangler deploy
26curl -X POST https://moonrise-apns-spike.<subdomain>.workers.dev/push \
27  -H "authorization: Bearer $SPIKE_SECRET" \
28  -d '{"token":"<device token hex>","sandbox":true}'
29#+end_src
30
31* test
32#+begin_src sh
33node --test test/
34#+end_src