spikes/apns-worker/README.org
34 lines · 1066 bytes
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