Skip to content

Instantly share code, notes, and snippets.

@xmkevinchen
Last active March 2, 2017 22:25
Show Gist options
  • Save xmkevinchen/97b5d548b3dd07a1071026b2869c8b0b to your computer and use it in GitHub Desktop.
Save xmkevinchen/97b5d548b3dd07a1071026b2869c8b0b to your computer and use it in GitHub Desktop.
Use `curl` to send remote notification with Apple Push Notification Service HTTP/2 api
# Generate Public / Private Keys
openssl pkcs12 -in <.p12> -out <private-key.pem> -nocerts -nodes
openssl pkcs12 -in <.p12> -out <public-key.pem> -clcerts -nokeys
# Reinstall curl with nghttp2
brew install / reinstall curl --with-nghttp2
# Replace Mac OS default curl
brew link curl --force
# POST
curl -v \
-d '{"aps": {"alert": "Hello World"}}' \
-H "apns-topic: <bundle-id>" \
--http2 \
--cert <public.pem> \
--key <private.pem> \
https://api.development.push.apple.com/3/device/<device-token>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment