Giter Site home page Giter Site logo

pns's Introduction

Push Notification Server

We have stopped working on this project. Consider using pushd instead.

Send push notifications via Google Cloud Messaging or the Apple Push Notification Service

Installation

Install NodeJS and run npm i -g pns

Server Configuration

Create pns.json:

{
  "port": 3005,
  "apps": [
    {
      "appId": "com.example.myapp",
      "gcm": {
        "apiKey": "xxx...",
        "senderID": "123..."
      },
      "apn": {
        "cert": "path/to/cert.pem",
        "key": "path/to/key.pem"
      }
    }
  ]
}

Configure your firewall to allow outgoing communication on port 2195:

sudo ufw allow out 2195

App Configuration

  1. Pick an identifier (e.g., com.example.myapp)
  2. Set the widget id to the identifier in config.xml and reset your cordova platforms (cordova prepare android|ios)
  3. Create a new entry in pns.json for your app and set appId to the chosen identifier

iOS (Mac only)

  1. Create an AppID with the chosen identifier in the iOS Member Center
  2. Enable Push Notifications for the AppId and generate development or production certificates
  3. Download and import the certificage into your Keychain
  4. Export the private key of the certificate via Keychain and run the following command:
openssl x509 -in aps_production.cer -inform DER -outform PEM -out APPID.pem
openssl pkcs12 -in aps_production.p12 -out APPID.key -nodes
  1. Add the cert and key paths to the app configuration in pns.json.

Android

  1. Register your application on the Google Developer Console
  2. Add the apiKey and senderId to the app configuration in pns.json.

Command Line Usage

Send a message:

pns [appId] [apn|gcm] [token] [title] [message] [payload]

Example:

pns com.example.myapp apn asd... "Hello world!" "This is my first push message." "{\"foo\":\"bar\"}"

Server Usage

Start the server:

pns -s

Send a post request to send a message:

POST http://localhost:3005/send
{
  "appId": "com.example.myapp",
  "token": "asd...",
  "platform": "gcm|apn",
  "title": "Hello world!",
  "body": "This is my first push message.",
  "payload": {
    "foo": "bar"
  }
}

pns's People

Contributors

jdiehl avatar the-jonasf avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.