Skip to content
forked from chanify/chanify

Chanify is a safe and simple notification tools. This repository is command line tools for Chanify.

License

Notifications You must be signed in to change notification settings

LitSummer/chanify

 
 

Repository files navigation

Chanify

Docker Release iTunes App Store Workflow Codecov GitHub Docker pull

English | 简体中文

Chanify is a safe and simple notification tools. For developers, system administrators, and everyone can push notifications with API.

Table of Contents

  1. Getting Started
  2. Installation
  3. Usage
  4. HTTP API
  5. Contributing
  6. License

Getting Started

  1. Install iOS App(1.0.0 version and above).
  2. Get send token, more detail.
  3. Send message.

Installation

Precompiled binary

Download precompiled binary from this.

Docker

$ docker pull wizjin/chanify:latest

From source

$ go install github.com/chanify/chanify

Usage

As Sender Client

Use chanify to send message.

$ chanify send --token=<token> --text=<message>

As Serverless node

Chanify run in stateless mode, no device token will be stored in node.

All device token will be stored in api.chanify.net.

Message will send to apple apns server by api.chanify.net.

Send message workflow:

Start => node server => api.chanify.net => Apple server => iOS client
# Start chanify
$ chanify serve --host=<ip address> --port=<port> --secret=<secret key> --name=<node name> --endpoint=http://<address>:<port>

# Docker
$ docker run -it wizjin/chanify:latest serve --secret=<secret key> --name=<node name> --endpoint=http://<address>:<port>

As Serverful node

Chanify run in stateful mode, device token will be stored in node.

Message will send to apple apns server direct.

Send message workflow:

Start => node server => Apple server => iOS client

Start server

# Start chanify
$ chanify serve --host=<ip address> --port=<port> --name=<node name> --datapath=~/.chanify --endpoint=http://<address>:<port>

# Docker
$ docker run -it -v /my/data:/root/.chanify wizjin/chanify:latest serve --name=<node name> --endpoint=http://<address>:<port>

Use MySQL as a backend

--dburl=mysql://<user>:<password>@tcp(<ip address>:<port>)/<database name>?charset=utf8mb4&parseTime=true&loc=Local

Chanify will not create database.

Add New Node

  • Start node server
  • iOS client can scan QRCode(http://<address>:<port>/) to add node.

Send message

Command Line

# Text message
$ curl --form-string "text=hello" "http://<address>:<port>/v1/sender/<token>"

# Text file
$ cat message.txt | curl -H "Content-Type: text/plain" --data-binary @- "http://<address>:<port>/v1/sender/<token>"

Python 3

from urllib import request, parse

data = parse.urlencode({ 'text': 'hello' }).encode()
req = request.Request("http://<address>:<port>/v1/sender/<token>", data=data)
request.urlopen(req)

Ruby

require 'net/http'

uri = URI('http://<address>:<port>/v1/sender/<token>')
res = Net::HTTP.post_form(uri, 'text' => 'hello')
puts res.body

NodeJS

const https = require('https')
const querystring = require('querystring');

const data = querystring.stringify({ text: 'hello' })
const options = {
    hostname: '<address>:<port>',
    port: 80,
    path: '/v1/sender/<token>',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': data.length
        }
    }
    var req = https.request(options, (res) => {
    res.on('data', (d) => {
        process.stdout.write(d);
    });
});  
req.write(data);
req.end();

HTTP API

  • GET
http://<address>:<port>/v1/sender/<token>/<message>
  • POST
http://<address>:<port>/v1/sender/<token>

Content-Type:

  • text/plain: Body is text message
  • multipart/form-data: The block of data("text") is text message
  • application/x-www-form-urlencoded: text=<url encoded text message>

Additional params

Key Description
title The title for notification message.
sound 1 enable sound, otherwise disable sound
priority 10 default, or 5

E.g.

http://<address>:<port>/v1/sender/<token>?sound=1&priority=10&title=hello

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

About

Chanify is a safe and simple notification tools. This repository is command line tools for Chanify.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.6%
  • Makefile 1.2%
  • Dockerfile 0.2%