Giter VIP home page Giter VIP logo

apns-push-cmd's Introduction

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.

apns-push-cmd's People

Contributors

dependabot[bot] avatar janc avatar petarov avatar yohanes avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

apns-push-cmd's Issues

Sending push from Windows

I'm trying to use the Windows version to send push notification.

Here is my command prompt:
apnscmd_windows_386 -cert-p12 "Test.p12" -token "2af6c2c33ca83e145cba2cd6d296387ba7303ecc1f45b6f6912fb78d766c34bb" -alert-text "Hello" -topic "com.sintesi.ibrama"

And this is the result:
apns-push-cmd v1.2 - Apple Push Notification service Command Line Push
2024/04/03 17:13:07 Sending... POST https://api.push.apple.com/3/device/2af6c2c33ca83e145cba2cd6d296387ba7303ecc1f45b6f6912fb78d766c34bb
POST /3/device/2af6c2c33ca83e145cba2cd6d296387ba7303ecc1f45b6f6912fb78d766c34bb HTTP/1.1
Host: api.push.apple.com
Apns-Expiration: 0
Apns-Push-Type: alert
Apns-Topic: com.sintesi.ibrama

2024/04/03 17:13:27 Error in HTTP request: Post "https://api.push.apple.com/3/device/2af6c2c33ca83e145cba2cd6d296387ba7303ecc1f45b6f6912fb78d766c34bb": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

Maybe it's related to HTTP/1.1?
I googled this error but it's a generic error, so I really don't know what's wrong.

Support for background pushes

Hi,
thanks for the open source project ๐Ÿ™

Would it be possible to add a parameter support for background notifications? Namely a parameter that can set the Apns-Push-Type header value to background as described in the Apple docs.

apns-push-cmd/main.go

Lines 369 to 373 in 2b17376

if len(MdmPushMagic) > 0 {
req.Header.Set("apns-push-type", "mdm")
} else {
req.Header.Set("apns-push-type", "alert")
}

thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.