Skip to content

jiajunhuang/obito

Folders and files

NameName
Last commit message
Last commit date

Latest commit

aea9b91 · Apr 24, 2018

History

18 Commits
Apr 24, 2018
Jul 17, 2017
Apr 24, 2018
Apr 24, 2018
Jul 17, 2017
Apr 24, 2018
Apr 24, 2018
Jul 16, 2017
Jul 19, 2017
Mar 23, 2018
Apr 24, 2018
Jul 16, 2017
Jul 16, 2017
Apr 24, 2018
Apr 24, 2018
Apr 24, 2018

Repository files navigation

iOS推送服务

我们直连APNs. 极光送达率真是感人...

本项目使用Redis + Golang打造,API请求延迟在1ms以内。

Table of Contents

使用方法:

$ git clone https://github.com/jiajunhuang/obito
$ cd obito
$ go build
$ # 另外需要crontab配合使用,定期清除已过期的key
$ cd cron
$ go build

开发工程中感谢iOS客户端童鞋的大力支持,谢谢!

redis中的key都比较长,后续如果内存吃紧,可以考虑使用更加短的方案,但是目前来说 还在可接受范围内

使用指南

首先,需要iOS端配合做好以下工作:

  • app在首次启动之后在沙箱内生成一个 uuid 作为唯一识别码
  • 每次打开app的时候获取 device_token 并且和上一次对比,如果发生了变化,则需要 调用 /report 上报新的 device_token ,完成 UUIDdevice_token 配对的更新
  • 每次打开app需要调用 /badge/clear 接口清除服务端存储的badge数量。

API

所有操作,如果成功,则返回:

状态码为200且json为

{
    "code": 200,
    "message": "",
    "result": {}
}

如果失败,则返回:

状态码为400,500等,且json为

{
    "code": 400,
    "message": "具体错误提示",
    "result": {}
}

给设备打tag

POST /tag

带上以下JSON:

{
    "uuid": "12345678-1730-4414-9728-95616073fe82",
    "tag_list": ["tag1", "tag2"]
}

给某个设备发送推送

POST /push

带上以下JSON:

{
    "uuid": "12345678-1730-4414-9728-95616073fe82",
    "content": "Hello, this is a test with very long somewhat"
}

清除badge

DELETE /badge

带上以下JSON:

{
    "uuid": "12345678-1730-4414-9728-95616073fe82"
}

按tag推送

POST /tag/push

带上以下JSON:

{
    "tag": "tag1",
    "content": "push_by_tag"
}

上报设备信息

POST /report

带上以下JSON:

{
    "uuid": "f8206027-8752-4850-bb20-3ae0f23d082e",
    "device_token": "12345678-1730-4414-9728-95616073fe82"
}

MIT License

About

an iOS notification service out of box

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published