Git Product home page Git Product logo

apns's Introduction

APNS

A command line tool to send push notifications using the Apple Push Notification Service.

Documentation

Send alert notifications

This command sends a user visible push notification to the device, with the given title and body:

apns send alert \
    -k private-key.p8 \
    --key-id ABCD123456 \
    --team-id ABCD123456 \
    -t com.example.app \
    -d <device-identifier> \
    --title "Hello world!" \
    --body "How are you?" \
    --sound

By default, it uses the sandbox APNS server. Add the -p flag to switch to production.

You can add a custom JSON payload to your notification:

apns send alert \
    -k private-key.p8 \
    --key-id ABCD123456 \
    --team-id ABCD123456 \
    -t com.example.app \
    -d <device-identifier> \
    --title "Hello world!" \
    --body "How are you?" \
    --sound \
    '{"hello":42}'

For more information:

apns send alert --help

Send background notifications

This command sends a background push notification to the device, with the given custom payload:

apns send background \
    -k private-key.p8 \
    --key-id ABCD123456 \
    --team-id ABCD123456 \
    -t com.example.app \
    -d <device-identifier> \
    '{"hello":42}'

For more information:

apns send background --help

Install, Update and Uninstall

The easiest way is to download a precompiled executable from the Releases page. The installer package is signed and notarised by Apple, it just installs the apns executable into /usr/local/bin.

Alternatively, you can build the project yourself (see below).

To uninstall, just remove /usr/local/bin/apns.

Build

Requirements

  • Xcode 15+ with Swift 5.9

Build for local deployment

Build the executable using:

swift build -c release

Then move the .build/release/apns executable to one of your $PATH directory, for example:

sudo cp .build/release/apns /usr/local/bin

Build for public distribution

For distribution, build the universal fat-executable using:

swift build -c release --arch arm64 --arch x86_64

This allows the executable to run on both Intel and Apple Silicon Macs.

apns's People

Contributors

tdimeco avatar

Stargazers

Michael Raber avatar

Watchers

 avatar

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.