Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/petarov/apns-push-cmd
Send APNs push notifications from your command line
https://github.com/petarov/apns-push-cmd
apns apns-http2 apns2 apple apple-push-notifications mdm push-notifications
Last synced: about 2 months ago
JSON representation
Send APNs push notifications from your command line
- Host: GitHub
- URL: https://github.com/petarov/apns-push-cmd
- Owner: petarov
- License: mit
- Created: 2020-10-10T19:53:20.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-19T13:50:10.000Z (8 months ago)
- Last Synced: 2024-10-11T15:17:16.833Z (2 months ago)
- Topics: apns, apns-http2, apns2, apple, apple-push-notifications, mdm, push-notifications
- Language: Go
- Homepage:
- Size: 75.2 KB
- Stars: 4
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mdm-dev - petarov/apns-push-cmd - Command line tool for sending app and MDM push notifications (Tools :hammer_and_wrench:)
README
APNs Command Line Push
===================================================![build](https://github.com/petarov/apns-push-cmd/workflows/CI%20Build/badge.svg)
[![goreport](https://goreportcard.com/badge/github.com/petarov/apns-push-cmd)](https://goreportcard.com/report/github.com/petarov/apns-push-cmd)Send your push notifications to Apple Push Notification service from the command line using HTTP/2.
Authentication Mechanism | Supported
---------------------------------|------------------------
Provider Authentication Tokens | yes :white_check_mark:
APNs provider certificate | yes :white_check_mark:# Installation
[Download binaries](https://github.com/petarov/apns-push-cmd/releases/tag/latest) 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.appSend 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 \
-token 'v2RwEsm69Go4aY4vSFY2pRLped2BMqETO3gDGBx7XmxKwSaKtZik7Q==' \
-topic com.apple.mgmt.External.462ad9c3-7ca1-437b-8c6f-5575941a4ea7 \
-mdm-magic 1AA91790-BA78-4DBF-9102-FBA06E6110C4Send 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.appSend 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.jsonShow 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](https://en.wikipedia.org/wiki/X.690#DER_encoding) encoded. [BER](https://en.wikipedia.org/wiki/X.690#BER_encoding) 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
- [Sending Notification Requests to APNs](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/)
- [Communicating with APNs](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html)# License
[MIT](LICENSE)
README icon by [Freepik](http://www.freepik.com/) from [Flaticon](https://www.flaticon.com/).