Chanify
English | 简体中文
Chanify is a safe and simple notification tools. For developers, system administrators, and everyone can push notifications with API.
Table of Contents
Features
Chanify is include these features:
- Customize channel for notifications.
- Deploy your own node server.
- Distributed architecture design.
- Design for privacy protection.
Getting Started
- Install iOS App(1.0.0 version and above).
- Get send token, more detail.
- 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.
# Text message
$ chanify send --endpoint=http://<address>:<port> --token=<token> --text=<message>
# URL message
$ chanify send --endpoint=http://<address>:<port> --token=<token> --link=<web url>
# Image message
$ chanify send --endpoint=http://<address>:<port> --token=<token> --image=<image file path>
# File message
$ chanify send --endpoint=http://<address>:<port> --token=<token> --file=<file path> --text=<file description>
endpoint
default value is https://api.chanify.net
, and notification will send by default server. If you have own node server, please set endpoint
to your node server url.
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://:
) to add node./
Send message
Command Line
# Text message
$ curl --form-string "text=hello" "http://:/v1/sender/"
# Text file
$ cat message.txt | curl -H "Content-Type: text/plain" --data-binary @- "http://:/v1/sender/"
Python 3
from urllib import request, parse
data = parse.urlencode({ 'text': 'hello' }).encode()
req = request.Request("http://:/v1/sender/" , data=data)
request.urlopen(req)
Ruby
require 'net/http'
uri = URI('http://:/v1/sender/' )
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: ':' ,
port: 80,
path: '/v1/sender/' ,
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();
PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'http://:/v1/sender/' ,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => [ 'text' => 'hello' ],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
HTTP API
Send Text
- GET
http://:/v1/sender//
- POST
http://:/v1/sender/
Content-Type:
text/plain
: Body is text messagemultipart/form-data
: The block of data("text") is text messageapplication/x-www-form-urlencoded
:text=
application/json; charset=utf-8
: The fields are optional
{
"token": "" ,
"title": "" ,
"text": "" ,
"copy": "" ,
"autocopy": 1,
"sound": 1,
"priority": 10,
}
Additional params
Key | Default | Description |
---|---|---|
title | None | The title for notification message. |
copy | None | The copy text for text notification. |
autocopy | 0 |
Enable autocopy text for text notification. |
sound | 0 |
1 enable sound, otherwise disable sound. |
priority | 10 |
10 normal, 5 lower level. |
E.g.
http://:/v1/sender/?sound=1&priority=10&title=hello©=123&autocopy=1
Send Link
$ curl --form "link=@" "http://:/v1/sender/"
{
"link": "" ,
"sound": 1,
"priority": 10,
}
Send Image
Send image only support POST method used serverful node.
- Content-Type:
image/png
ORimage/jpeg
cat <jpeg image path> | curl -H "Content-Type: image/jpeg" --data-binary @- "http://:/v1/sender/"
- Content-Type:
multipart/form-data
$ curl --form "image=@" "http://:/v1/sender/"
Send File
Send file only support POST method used serverful node.
- Content-Type:
multipart/form-data
$ curl --form "file=@" "http://:/v1/sender/"
Configuration
Chanify can be configured with a yml format file, and the default path is ~/.chanify.yml
.
server:
host: 0.0.0.0 # Listen ip address
port: 8080 # Listen port
endpoint: http://my.server/path # Endpoint URL
name: Node name # Name for node server
secret: # key for serverless node server
datapath: # data storage path for serverful node server
dburl: mysql://root:[email protected](127.0.0.1:3306)/chanify?charset=utf8mb4&parseTime=true&loc=Local # database dsn for serverful node server
register:
enable: false # Disable user register
whitelist: # whitelist for user register
-
-
client: # configuration for sender client
sound: 1 # enable sound
endpoint:
token:
Security
Node server can be disabled user registration and become a private server.
chanify serve --registerable=false --whitelist=<user1 id>,<user2 id>
--registerable=false
: used to disable user registrationwhitelist
: list users can be add into node server
Chrome Extension
Download the extension for Chrome web store.
Extension features:
- Send select
text/image/url
message to Chanify - Send page url to Chanify
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.
- Fork the Project
- Change to dev Branch (
git checkout dev
) - Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request (merge to
chanify:dev
branch)
License
Distributed under the MIT License. See LICENSE
for more information.