How to send push notifications to iOS devices with the curl command.
Create a PEM file that includes both the certificate and the private key.
$ openssl pkcs12 -in xxxx.p12 -nodes -out certificate-and-privatekey.pem
The curl
command is used to send a push notification.
Push payloads, topics, and debit tokens should be from your environment.
Also, be aware that the domain (https://api.push.apple.com/3/device/ or https://api.development.push.apple.com) is different between the production environment (e.g. test flights) and the development environment.
# Production Server
$ curl -v -d '{"aps":{"alert":"hello"}}' -H "apns-topic: com.swiswiswift.myapp" --http2 --cert certificate-and-privatekey.pem https://api.push.apple.com/3/device/{your_device_token}
# Staging Server
$ curl -v -d '{"aps":{"alert":"hello"}}' -H "apns-topic: com.swiswiswift.myapp" --http2 --cert certificate-and-privatekey.pem https://api.development.push.apple.com/3/device/{your_device_token}