Skip to content

Files

Latest commit

 

History

History
185 lines (133 loc) · 4.43 KB

README-zh_CN.md

File metadata and controls

185 lines (133 loc) · 4.43 KB

Chanify

iTunes App Store GitHub

English | 简体中文

Chanify是一个简单的消息推送工具。每一个人都可以利用提供的API来发送消息推送到自己的iOS设备上。

你还可以部署自己的服务器

Table of Contents

  1. 入门
  2. 用法
  3. 开发者
  4. 贡献
  5. 许可证

入门

  1. 从AppStore安装iOS应用(1.0.0或以上版本)。

  2. 从频道详情页面来获取发送使用的令牌token

    Get token

  3. 使用API来发送消息。

  4. 也可以通过长按扫描二维码图标来进入创建频道,创建自定义的频道。

    NewChannel

用法

Http API

  • GET 方式
https://api.chanify.net/v1/sender/<token>/<message>
  • POST 方式
https://api.chanify.net/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>

支持以下参数:

参数名 描述
title 通知消息的标题
sound 1 启用声音提示, 其他情况会静音推送
priority 10 默认优先级, 或者 5 较低优先级

例如:

https://api.chanify.net/v1/sender/<token>?sound=1&priority=10&title=hello

命令行

# 发送文本消息
$ curl --form-string "text=hello" "https://api.chanify.net/v1/sender/<token>"

# 发送文本文件
$ cat message.txt | curl -H "Content-Type: text/plain" --data-binary @- "https://api.chanify.net/v1/sender/<token>"

Python 3

from urllib import request, parse

data = parse.urlencode({ 'text': 'hello' }).encode()
req = request.Request("https://api.chanify.net/v1/sender/<token>", data=data)
request.urlopen(req)

Ruby

require 'net/http'

uri = URI('https://api.chanify.net/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: 'api.chanify.net',
    port: 443,
    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();

PHP

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL           => 'http://<address>:<port>/v1/sender/<token>',
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS    => [ 'text' => 'hello' ],
]);

$response = curl_exec($curl);

curl_close($curl);
echo $response;

开发者

依赖第三方工具:

  • protobuf

初始化项目依赖

$ pod install

可以使用下列命令给模拟器发送推送用于测试

$ ./send.swift text=hello

贡献

贡献使开源社区成为了一个令人赞叹的学习,启发和创造场所。 十分感谢您做出的任何贡献。

  1. Fork本项目
  2. 创建您的Feature分支 (git checkout -b feature/AmazingFeature)
  3. 提交您的更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启一个Pull Request

许可证

根据MIT许可证分发,详情查看LICENSE