Based on Sending Push Notifications Using Command-Line Tools, these shell variables were set after making a new CSR, App ID, and obtaining a new provider certificate from Apple:
CERTIFICATE_FILE_NAME=/Users/developer/desktop/aps.cer
CERTIFICATE_KEY_FILE_NAME=/Users/developer/desktop/PushChatKey.p12
TOPIC=com.domainname.appname
DEVICE_TOKEN=af59ba83a511f21f343df63ebd1bcd32225878e7d9401a4e933a3caf0cf55a63
APNS_HOST_NAME=api.sandbox.push.apple.com
The following terminal command was entered to send a test push notification:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
This was the resulting terminal output:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
* Could not resolve host: com.domainname.appname
* Closing connection 0
curl: (6) Could not resolve host: com.domainname.appname
* Could not resolve host: alert
* Closing connection 1
curl: (6) Could not resolve host: alert
* Trying 17.188.138.71...
* TCP_NODELAY set
* Connected to api.sandbox.push.apple.com (17.188.138.71) port 443 (#2)
* ALPN, offering h2
* ALPN, offering http/1.1
Enter PEM pass phrase:
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS handshake, CERT verify (15):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=api.development.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US
* start date: Feb 8 21:41:22 2021 GMT
* expire date: Mar 10 21:41:22 2022 GMT
* subjectAltName: host "api.sandbox.push.apple.com" matched cert's "api.sandbox.push.apple.com"
* issuer: CN=Apple Public Server RSA CA 12 - G1; O=Apple Inc.; ST=California; C=US
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fe70780d600)
> POST /3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1 HTTP/2
> Host: api.sandbox.push.apple.com
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 24
> Content-Type: application/x-www-form-urlencoded
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 1000)!
* We are completely uploaded and fine
< HTTP/2 400
< apns-id: E9EC6D23-7E07-BA0A-B574-F478271AE803
<
* Connection #2 to host api.sandbox.push.apple.com left intact
{"reason":"MissingTopic"}* Closing connection 2
How can this be fixed?