Skip to content

petarov/apns-push-cmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APNs Command Line Push

build goreport

Send your push notifications to Apple Push Notification service from the command line using HTTP/2.

Authentication Mechanism Supported
Provider Authentication Tokens yes ✅
APNs provider certificate yes ✅

Installation

Download binaries for Linux, macOS and Windows.

Usage

Send a push notification to your app using certificate-based authentication:

apnscmd_linux_amd64 -cert-file app-cert.pem -cert-key app-private.pem \
    -token c7b68e4eb7d604876bf5836133479ffa49449c669f7e6b79318ae59032e83c24 \
    -topic com.my.app

Send an MDM push notification using certificate-based authentication with a PKCS#12 keystore and Base64 encoded device token:

apnscmd_linux_amd64 -cert-p12 apns.p12 -cert-pass <my password> \
    -token 'v2RwEsm69Go4aY4vSFY2pRLped2BMqETO3gDGBx7XmxKwSaKtZik7Q==' \
    -topic com.apple.mgmt.External.462ad9c3-7ca1-437b-8c6f-5575941a4ea7 \
    -mdm-magic 1AA91790-BA78-4DBF-9102-FBA06E6110C4

Send a push notification to your app using token-based authentication:

apnscmd_linux_amd64 -auth-token AuthKey_BBC42Y2321.p8 -key-id BBC42Y2321 -team-id YXB7430FC8 \
    -token c7b68e4eb7d604876bf5836133479ffa49449c669f7e6b79318ae59032e83c24 \
    -topic com.my.app

Send a custom push notification to your app using token-based authentication with the JSON message specified in the command line:

apnscmd_linux_amd64 -auth-token AuthKey_BBC42Y2321.p8 -key-id BBC42Y2321 -team-id YXB7430FC8 \
    -token c7b68e4eb7d604876bf5836133479ffa49449c669f7e6b79318ae59032e83c24 \
    -topic com.my.app -alert-json '{"aps": {"alert" : "test", "sound": "default"}, "custom":"custom value"}'

Send a custom push notification to your app using token-based authentication with the JSON message read from a file:

apnscmd_linux_amd64 -auth-token AuthKey_BBC42Y2321.p8 -key-id BBC42Y2321 -team-id YXB7430FC8 \
    -token c7b68e4eb7d604876bf5836133479ffa49449c669f7e6b79318ae59032e83c24 \
    -topic com.my.app -alert-filename custom.json

Show all available arguments:

apnscmd_linux_amd64 -h

The -auth-token argument always takes prescedence overt the -cert-* arguments.

Extract keys from PKCS#12

If you're using a PKCS#12 keystore, then it must be DER encoded. BER encoded keystores are not supported. You'll need to manually break down a BER encoded keystore into certificate and private key files.

To extract private key file from a PKCS#12 container use:

openssl pkcs12 -info -in apns-production.p12 -nodes -nocerts -out apns-private.pem

To extrcat certificate file from a PKCS#12 container use:

openssl pkcs12 -info -in apns-production.p12 -nokeys -out apns-cert.pem

Development

License

MIT

README icon by Freepik from Flaticon.