jpush 4.0.10 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +12 -12
- data/.travis.yml +7 -7
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +60 -60
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/docs/Guides.md +619 -619
- data/jpush.gemspec +35 -35
- data/lib/jpush.rb +8 -8
- data/lib/jpush/client.rb +43 -43
- data/lib/jpush/device.rb +163 -163
- data/lib/jpush/handler.rb +7 -7
- data/lib/jpush/http/client.rb +100 -100
- data/lib/jpush/http/response.rb +33 -33
- data/lib/jpush/push/audience.rb +55 -55
- data/lib/jpush/push/notification.rb +66 -66
- data/lib/jpush/push/push_payload.rb +77 -77
- data/lib/jpush/push/single_push_payload.rb +52 -52
- data/lib/jpush/pusher.rb +84 -84
- data/lib/jpush/report.rb +98 -98
- data/lib/jpush/schedule/schedule_payload.rb +48 -48
- data/lib/jpush/schedule/trigger.rb +53 -53
- data/lib/jpush/schedules.rb +53 -53
- data/lib/jpush/utils/exceptions.rb +34 -34
- data/lib/jpush/version.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42b6ce606be8618cb4e7833391fcb0de9a7308a43e033ed3fd4fb0ab00372523
|
4
|
+
data.tar.gz: 64f3ca76df9712bc722dbb7b5b2fb5d31d6841cfc4b4d63c8247b91a04b452f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6314314750528744762cd7c11e4805f5aa1c8704ffebf1c6a907bf89b4c91880c0ac75ffe08876a5a23dd50e2184b62a466a8f3e228763cd9dba063dd5b24677
|
7
|
+
data.tar.gz: e461980994a80f5fca0e6e034879dee84b8dbd755314a593912fbc8fa2064f14e0ee640b49d6293f4e80a1aa513848d983e9c09b4aeb85e1e593f50cb2787371
|
data/.gitignore
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/Gemfile.lock
|
4
|
-
/_yardoc/
|
5
|
-
/coverage/
|
6
|
-
/doc/
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
10
|
-
/test/config.yml
|
11
|
-
*~
|
12
|
-
/.idea
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
/test/config.yml
|
11
|
+
*~
|
12
|
+
/.idea
|
data/.travis.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3.0
|
4
|
-
- 2.2.0
|
5
|
-
before_install: gem install bundler -v 1.11.2
|
6
|
-
|
7
|
-
before_script: cp test/config.yml.example test/config.yml
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.3.0
|
4
|
+
- 2.2.0
|
5
|
+
before_install: gem install bundler -v 1.11.2
|
6
|
+
|
7
|
+
before_script: cp test/config.yml.example test/config.yml
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in jpush.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in jpush.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2016 Helperhaps
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Helperhaps
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
# JPush API Ruby Client
|
2
|
-
|
3
|
-
[](https://travis-ci.org/jpush/jpush-api-ruby-client)
|
4
|
-
[](https://badge.fury.io/rb/jpush)
|
5
|
-
|
6
|
-
这是 JPush REST API 的 Ruby 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。
|
7
|
-
|
8
|
-
对应的 REST API 文档: https://docs.jiguang.cn/jpush/server/push/server_overview/
|
9
|
-
|
10
|
-
> 支持的 Ruby 版本:>= 2.2
|
11
|
-
|
12
|
-
## Installation
|
13
|
-
|
14
|
-
Add this line to your application's Gemfile:
|
15
|
-
|
16
|
-
```ruby
|
17
|
-
gem 'jpush'
|
18
|
-
# OR
|
19
|
-
gem 'jpush', git: 'https://github.com/jpush/jpush-api-ruby-client.git'
|
20
|
-
```
|
21
|
-
|
22
|
-
## Usage
|
23
|
-
|
24
|
-
- [Getting Started](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#getting-started)
|
25
|
-
- [Push API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#push-api)
|
26
|
-
- [Report API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#report-api)
|
27
|
-
- [Schedule API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#schedule-api)
|
28
|
-
- [Device API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#device-api)
|
29
|
-
- [Http2 Support](https://github.com/jpush/jpush-api-ruby-client/tree/http2)
|
30
|
-
|
31
|
-
## Development
|
32
|
-
|
33
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
-
|
35
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
-
|
37
|
-
## Testing
|
38
|
-
|
39
|
-
```bash
|
40
|
-
# 复制测试的配置文件
|
41
|
-
$ cp test/config.yml.example test/config.yml
|
42
|
-
|
43
|
-
# 编辑 test/config.yml 文件,填入必须的变量值
|
44
|
-
# OR 设置相应的环境变量
|
45
|
-
|
46
|
-
# 运行全部测试用例
|
47
|
-
$ bundle exec rake
|
48
|
-
|
49
|
-
# 运行某一具体测试用例
|
50
|
-
$ bundle exec rake test TEST=test/jpush/xx_test.rb
|
51
|
-
```
|
52
|
-
|
53
|
-
## Contributing
|
54
|
-
|
55
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/jpush/jpush-api-ruby-client.
|
56
|
-
|
57
|
-
|
58
|
-
## License
|
59
|
-
|
60
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
1
|
+
# JPush API Ruby Client
|
2
|
+
|
3
|
+
[](https://travis-ci.org/jpush/jpush-api-ruby-client)
|
4
|
+
[](https://badge.fury.io/rb/jpush)
|
5
|
+
|
6
|
+
这是 JPush REST API 的 Ruby 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。
|
7
|
+
|
8
|
+
对应的 REST API 文档: https://docs.jiguang.cn/jpush/server/push/server_overview/
|
9
|
+
|
10
|
+
> 支持的 Ruby 版本:>= 2.2
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'jpush'
|
18
|
+
# OR
|
19
|
+
gem 'jpush', git: 'https://github.com/jpush/jpush-api-ruby-client.git'
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
- [Getting Started](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#getting-started)
|
25
|
+
- [Push API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#push-api)
|
26
|
+
- [Report API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#report-api)
|
27
|
+
- [Schedule API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#schedule-api)
|
28
|
+
- [Device API](https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#device-api)
|
29
|
+
- [Http2 Support](https://github.com/jpush/jpush-api-ruby-client/tree/http2)
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
## Testing
|
38
|
+
|
39
|
+
```bash
|
40
|
+
# 复制测试的配置文件
|
41
|
+
$ cp test/config.yml.example test/config.yml
|
42
|
+
|
43
|
+
# 编辑 test/config.yml 文件,填入必须的变量值
|
44
|
+
# OR 设置相应的环境变量
|
45
|
+
|
46
|
+
# 运行全部测试用例
|
47
|
+
$ bundle exec rake
|
48
|
+
|
49
|
+
# 运行某一具体测试用例
|
50
|
+
$ bundle exec rake test TEST=test/jpush/xx_test.rb
|
51
|
+
```
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jpush/jpush-api-ruby-client.
|
56
|
+
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList['test/**/*_test.rb']
|
8
|
-
end
|
9
|
-
|
10
|
-
task :default => :test
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :test
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "jpush"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jpush"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/docs/Guides.md
CHANGED
@@ -1,619 +1,619 @@
|
|
1
|
-
# 目录
|
2
|
-
|
3
|
-
- [Getting Started](#getting-started)
|
4
|
-
- [Push API](#push-api)
|
5
|
-
- [构建 Audience 对象](#构建-audience-对象)
|
6
|
-
- [构建 Notification 对象](#构建-notification-对象)
|
7
|
-
- [构建 PushPayload 对象](#构建-pushpayload-对象)
|
8
|
-
- [推送消息](#推送消息)
|
9
|
-
- [构建 SinglePushPayload 对象](#构建-SinglePushPayload-对象)
|
10
|
-
- [批量单推(VIP专属接口)](#批量单推vip专属接口)
|
11
|
-
- [Report API](#report-api)
|
12
|
-
- [送达统计(旧)](#送达统计旧)
|
13
|
-
- [送达统计详情(新)](#送达统计详情新)
|
14
|
-
- [送达状态查询](#送达状态查询)
|
15
|
-
- [消息统计(VIP专属接口,旧)](#消息统计vip专属接口旧)
|
16
|
-
- [消息统计详情(VIP 专属接口,新)](#消息统计详情vip-专属接口新)
|
17
|
-
- [用户统计(VIP专属接口)](#用户统计vip专属接口)
|
18
|
-
- [Schedule API](#schedule-api)
|
19
|
-
- [构建 Trigger 对象](#构建-trigger-对象)
|
20
|
-
- [构建 SchedulePayload 对象](#构建-schedulepayload-对象)
|
21
|
-
- [创建定时任务](#创建定时任务)
|
22
|
-
- [获取有效的定时任务列表](#获取有效的定时任务列表)
|
23
|
-
- [获取定时任务详情](#获取定时任务详情)
|
24
|
-
- [更新定时任务](#更新定时任务)
|
25
|
-
- [删除定时任务](#删除定时任务)
|
26
|
-
- [Device API](#device-api)
|
27
|
-
- [查询设备](#查询设备-设备的别名与标签)
|
28
|
-
- [更新设备](#更新设备-设备的别名与标签)
|
29
|
-
- [获取用户在线状态(VIP专属接口)](#获取用户在线状态vip专属接口)
|
30
|
-
- [查询标签列表](#查询标签列表)
|
31
|
-
- [判断设备与标签的绑定](#判断设备与标签的绑定)
|
32
|
-
- [更新标签](#更新标签-与设备的绑定的关系)
|
33
|
-
- [删除标签](#删除标签-与设备的绑定关系)
|
34
|
-
- [查询别名](#查询别名-与设备的绑定关系)
|
35
|
-
- [删除别名](#删除别名-与设备的绑定关系)
|
36
|
-
|
37
|
-
## Getting Started
|
38
|
-
|
39
|
-
[Where to get app_key or master_secret?](https://www.jpush.cn/common/apps/new)
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
app_key = 'xxx'
|
43
|
-
master_secret = 'xxx'
|
44
|
-
jpush = JPush::Client.new(app_key, master_secret)
|
45
|
-
```
|
46
|
-
|
47
|
-
## Push API
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
pusher = jpush.pusher
|
51
|
-
|
52
|
-
# simplest push Hello to all
|
53
|
-
push_payload = JPush::Push::PushPayload.new(
|
54
|
-
platform: 'all',
|
55
|
-
audience: 'all',
|
56
|
-
notification: 'hello jpush',
|
57
|
-
message: 'hello world'
|
58
|
-
)
|
59
|
-
pusher.push(push_payload)
|
60
|
-
```
|
61
|
-
|
62
|
-
#### 构建 Audience 对象
|
63
|
-
|
64
|
-
推送设备对象,表示一条推送可以被推送到哪些设备列表。
|
65
|
-
如果要发广播(全部设备),不需要构建 Audience 对象,在新建 PushPayload 对象的时候,给 'audience' 参数直接传递字符串 'all' 即可。
|
66
|
-
广播外的设备选择方式,有4种类型: tag, tag_and, tag_not, alias, registration_id, **5 种类型至少需要有其一, 这几种类型并存时多项的隐含关系是 AND,即取交集**
|
67
|
-
|
68
|
-
```ruby
|
69
|
-
audience = JPush::Push::Audience.new
|
70
|
-
audience.set_tag(tag)
|
71
|
-
audience.set_tag_and(tag_and)
|
72
|
-
audience.set_tag_not(tag_not)
|
73
|
-
audience.set_alias(alis)
|
74
|
-
audience.set_registration_id(registration_ids)
|
75
|
-
|
76
|
-
# 链式调用
|
77
|
-
audience = JPush::Push::Audience.new.
|
78
|
-
set_tag(tag).
|
79
|
-
set_tag_and(tag_and).
|
80
|
-
set_tag_not(tag_not).
|
81
|
-
set_alias(alis).
|
82
|
-
set_registration_id(registration_ids)
|
83
|
-
```
|
84
|
-
|
85
|
-
参数说明
|
86
|
-
|
87
|
-
| 参数 | 是否必须 | 说明 |
|
88
|
-
| --- | :---: | --- |
|
89
|
-
| tag | 否 | 有效的标签字符串或者一个最多包含20个有效的标签字符串的数组 |
|
90
|
-
| tag_and | 否 | 有效的标签字符串或者一个最多包含20个有效的标签字符串的数组 |
|
91
|
-
| tag_not | 否 | 有效的标签字符串或者一个最多包含20个有效的标签字符串的数组 |
|
92
|
-
| alis | 否 | 有效的别名字符串或者一个最多包含1000个有效的别名字符串的数组 |
|
93
|
-
| registration_ids | 否 | 有效的 registration id 字符串或者一个最多包含1000个有效的 registration id 字符串的数组 |
|
94
|
-
|
95
|
-
#### 构建 Notification 对象
|
96
|
-
|
97
|
-
若通知的内容在各个平台上,都只有 'alert' 这一个最基本的属性,
|
98
|
-
则不需要构建 Notifacation 对象,在新建 PushPayload 对象的时候,给 'notication' 参数直接传递表示 alert 的字符串即可,
|
99
|
-
也可以在 Notifacation 对象中设置 alert 属性。另外 IOS 的 alert 还支持 Hash 对象的参数。
|
100
|
-
其下属属性包含3种,2个平台属性,以及一个 'alert' 属性。
|
101
|
-
|
102
|
-
```ruby
|
103
|
-
notification = JPush::Push::Notification.new
|
104
|
-
```
|
105
|
-
|
106
|
-
###### alert
|
107
|
-
|
108
|
-
```ruby
|
109
|
-
notification.set_alert(alert)
|
110
|
-
```
|
111
|
-
|
112
|
-
###### android
|
113
|
-
|
114
|
-
```ruby
|
115
|
-
notification.set_android(
|
116
|
-
alert: alert,
|
117
|
-
title: title,
|
118
|
-
builder_id: builder_id,
|
119
|
-
channel_id: channel_id,
|
120
|
-
extras: extras
|
121
|
-
)
|
122
|
-
```
|
123
|
-
|
124
|
-
参数说明
|
125
|
-
|
126
|
-
| 参数 | 是否必须 | 说明 |
|
127
|
-
| --- | :---: | --- |
|
128
|
-
| alert | 是 | 表示通知内容,会覆盖上级统一指定的 alert 信息;内容可以为空字符串,表示不展示到通知栏 |
|
129
|
-
| title | 否 | 表示通知标题,会替换通知里原来展示 App 名称的地方 |
|
130
|
-
| builder_id | 否 | 表示通知栏样式 ID,Android SDK 可设置通知栏样式,这里根据样式 ID 来指定该使用哪套样式 |
|
131
|
-
| channel_id | 否 | 不超过1000字节,Android 8.0开始可以进行NotificationChannel配置,这里根据channel ID 来指定通知栏展示效果。 |
|
132
|
-
| priority | 否 | 表示通知栏展示优先级,默认为 0,范围为 -2~2 ,其他值将会被忽略而采用默认值 |
|
133
|
-
| category | 否 | 表示通知栏条目过滤或排序,完全依赖 rom 厂商对 category 的处理策略 |
|
134
|
-
| style | 否 | 表示通知栏样式类型,默认为 0,还有1,2,3 可选,用来指定选择哪种通知栏样式,其他值无效。有三种可选分别为 bigText = 1,Inbox = 2,bigPicture = 3 |
|
135
|
-
| alert_type | 否 | 表示通知提醒方式, 可选范围为 -1~7 ,对应 Notification.DEFAULT_ALL = -1 或者 Notification.DEFAULT_SOUND = 1, Notification.DEFAULT_VIBRATE = 2, Notification.DEFAULT_LIGHTS = 4 的任意 “or” 组合。默认按照 -1 处理。 |
|
136
|
-
| big_text | 否 | 表示大文本通知栏样式,当 style = 1 时可用,内容会被通知栏以大文本的形式展示出来,支持 api 16 以上的 rom |
|
137
|
-
| inbox | 否 | 表示文本条目通知栏样式,接受一个数组,当 style = 2 时可用,数组的每个 key 对应的 value 会被当作文本条目逐条展示,支持 api 16 以上的 rom |
|
138
|
-
| big_pic_path | 否 | 表示大图片通知栏样式,当 style = 3 时可用,可以是网络图片 url,或本地图片的 path,目前支持 .jpg 和 .png 后缀的图片。图片内容会被通知栏以大图片的形式展示出来。如果是 http/https 的 url,会自动下载;如果要指定开发者准备的本地图片就填 sdcard 的相对路径,支持 api 16 以上的 rom |
|
139
|
-
| extras | 否 | 表示扩展字段,接受一个 Hash 对象,以供业务使用 |
|
140
|
-
|
141
|
-
###### ios
|
142
|
-
|
143
|
-
```ruby
|
144
|
-
notification.set_ios(
|
145
|
-
alert: alert,
|
146
|
-
sound: sound,
|
147
|
-
badge: badge,
|
148
|
-
contentavailable: contentavailable,
|
149
|
-
mutablecontent: mutablecontent,
|
150
|
-
category: category,
|
151
|
-
extras: extras
|
152
|
-
)
|
153
|
-
```
|
154
|
-
|
155
|
-
参数说明
|
156
|
-
|
157
|
-
| 参数 | 是否必须 | 说明 |
|
158
|
-
| --- | :---: | --- |
|
159
|
-
| alert | 是 | 表示通知内容,会覆盖上级统一指定的 alert 信息;内容可以为空字符串,表示不展示到通知栏 |
|
160
|
-
| sound | 否 | 表示通知提示声音 |
|
161
|
-
| badge | 否 | 表示应用角标,把角标数字改为指定的数字;为 0 表示清除,若不填默认是默认是 +1 |
|
162
|
-
| contentavailable | 否 | 表示推送唤醒,仅接受 true 表示为 Background Remote Notification,若不填默认是 nil 表示普通的 Remote Notification |
|
163
|
-
| mutablecontent | 否 | 表示通知扩展,仅接受 true 表示支持 iOS10 的 UNNotificationServiceExtension,若不填默认是 nil 表示普通的 Remote Notification |
|
164
|
-
| category | 否 | IOS8才支持。设置 APNs payload 中的 'category' 字段值 |
|
165
|
-
| extras | 否 | 表示扩展字段,接受一个 Hash 对象,以供业务使用 |
|
166
|
-
|
167
|
-
###### 链式调用
|
168
|
-
|
169
|
-
```ruby
|
170
|
-
notification = JPush::Push::Notification.new.
|
171
|
-
set_alert(alert).
|
172
|
-
set_android(
|
173
|
-
alert: alert,
|
174
|
-
title: title,
|
175
|
-
builder_id: builder_id,
|
176
|
-
extras: extras
|
177
|
-
).set_ios(
|
178
|
-
alert: alert,
|
179
|
-
sound: sound,
|
180
|
-
badge: badge,
|
181
|
-
contentavailable: contentavailable,
|
182
|
-
mutablecontent: mutablecontent,
|
183
|
-
category: category,
|
184
|
-
extras: extras
|
185
|
-
)
|
186
|
-
```
|
187
|
-
|
188
|
-
#### 构建 PushPayload 对象
|
189
|
-
|
190
|
-
一个推送对象,表示一条推送相关的所有信息,通知内容体。是被推送到客户端的内容。
|
191
|
-
**notification 和 message 二者必须有其一,可以二者并存。**
|
192
|
-
**如果目标平台有 iOS 平台 需要在 options 中通过 apns_production 字段来制定推送环境。True 表示推送生产环境,False 表示要推送开发环境; 如果不指定则为推送生产环境。**
|
193
|
-
|
194
|
-
```ruby
|
195
|
-
# audience 和 notification 对象可按照上面的例子实例化
|
196
|
-
audience = JPush::Push::Andience.new.set_registration_id(registration_ids)
|
197
|
-
notification = JPush::Push::Notification.new.set_alert(alert)
|
198
|
-
```
|
199
|
-
|
200
|
-
```ruby
|
201
|
-
# 初始化 PushPayload 对象
|
202
|
-
push_payload = JPush::Push::PushPayload.new(
|
203
|
-
platform: platform,
|
204
|
-
audience: audience,
|
205
|
-
notification: notification,
|
206
|
-
message: message
|
207
|
-
)
|
208
|
-
```
|
209
|
-
|
210
|
-
参数说明
|
211
|
-
|
212
|
-
| 参数 | 是否必须 | 说明 |
|
213
|
-
| --- | :---: | --- |
|
214
|
-
| platform | 是 | 表示推送的平台,其可接受的参数为 'all'(表示推送到所有平台), 'android' 或 'ios' 或 ['android', 'ios'] |
|
215
|
-
| audience | 是 | 表示推送的设备,其可接受的参数为 'all' (表示发广播,推送到全部设备) 或者一个 Audience 对象 |
|
216
|
-
| notification | 否 | 接受一个字符串快速设置最基本的 'alert' 属性,或者一个 Notifcation 对象 |
|
217
|
-
| message | 否 | 表示应用内消息,仅接受一个字符串来快速设置消息内容本身,要构建复杂的 Message 对象,需使用 PushPayload 的实例方法 set_message |
|
218
|
-
|
219
|
-
###### 添加应用内消息
|
220
|
-
|
221
|
-
```ruby
|
222
|
-
push_payload = JPush::Push::PushPayload.new(
|
223
|
-
platform: platform,
|
224
|
-
audience: audience,
|
225
|
-
notification: notification,
|
226
|
-
).set_message(
|
227
|
-
msg_content,
|
228
|
-
title: title,
|
229
|
-
content_type: content_type,
|
230
|
-
extras: extras
|
231
|
-
)
|
232
|
-
```
|
233
|
-
|
234
|
-
参数说明
|
235
|
-
|
236
|
-
| 参数 | 是否必须 | 说明 |
|
237
|
-
| --- | :---: | --- |
|
238
|
-
| msg_content | 是 | 消息内容本身 |
|
239
|
-
| title | 否 | 消息标题 |
|
240
|
-
| content_type | 否 | 消息内容类型 |
|
241
|
-
| extras | 否 | 表示扩展字段,接受一个 Hash 对象,以供业务使用 |
|
242
|
-
|
243
|
-
###### 添加短信业务
|
244
|
-
|
245
|
-
```ruby
|
246
|
-
push_payload = JPush::Push::PushPayload.new(
|
247
|
-
platform: platform,
|
248
|
-
audience: audience,
|
249
|
-
notification: notification
|
250
|
-
)
|
251
|
-
sms_message = {
|
252
|
-
delay_time: delay_time,
|
253
|
-
signid: signid,
|
254
|
-
temp_id: temp_id,
|
255
|
-
temp_para: temp_para,
|
256
|
-
active_filter: active_filter
|
257
|
-
}
|
258
|
-
push_payload.set_sms_message(sms_message)
|
259
|
-
```
|
260
|
-
|
261
|
-
参数说明
|
262
|
-
|
263
|
-
| 参数 | 是否必须 | 说明 |
|
264
|
-
| --- | :---: | --- |
|
265
|
-
| delay_time | 是 | 单位为秒,不能超过 24 小时。设置为 0,表示立即发送短信。该参数仅对 android 和 iOS 平台有效,Winphone 平台则会立即发送短信。 |
|
266
|
-
| signid | 否 | 签名ID,该字段为空则使用应用默认签名。 |
|
267
|
-
| temp_id | 是 | 短信补充的内容模板 ID。没有填写该字段即表示不使用短信补充功能。 |
|
268
|
-
| temp_para | 否 | 短信模板中的参数。 |
|
269
|
-
| active_filter | 否 | active_filter 字段用来控制是否对补发短信的用户进行活跃过滤,默认为 true ,做活跃过滤;为 false,则不做活跃过滤; |
|
270
|
-
|
271
|
-
###### 推送可选项
|
272
|
-
|
273
|
-
```ruby
|
274
|
-
options = {
|
275
|
-
sendno: no,
|
276
|
-
time_to_live: time,
|
277
|
-
override_msg_id: msg_id,
|
278
|
-
apns_production: true,
|
279
|
-
big_push_duration: duration
|
280
|
-
}
|
281
|
-
|
282
|
-
# 参数 options 仅接受一个 Hash 对象,而这个 Hash 对象的键也仅支持上面所示的5种。
|
283
|
-
push_payload = JPush::Push::PushPayload.new(
|
284
|
-
platform: platform,
|
285
|
-
audience: audience,
|
286
|
-
notification: notification,
|
287
|
-
message: message
|
288
|
-
).set_options(options)
|
289
|
-
```
|
290
|
-
|
291
|
-
参数说明
|
292
|
-
|
293
|
-
| 可选项 | 说明 |
|
294
|
-
| --- | --- |
|
295
|
-
| sendno | 表示推送序号,纯粹用来作为 API 调用标识,API 返回时被原样返回,以方便 API 调用方匹配请求与返回 |
|
296
|
-
| time_to_live | 表示离线消息保留时长(秒),推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到 |
|
297
|
-
| override_msg_id | 表示要覆盖的消息ID |
|
298
|
-
| apns_production | 表示APNs是否生产环境,True 表示推送生产环境,False 表示要推送开发环境;如果不指定则为推送开发环境 |
|
299
|
-
| big_push_duration | 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,给定的n分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送 |
|
300
|
-
|
301
|
-
###### 链式调用
|
302
|
-
|
303
|
-
```ruby
|
304
|
-
push_payload = JPush::Push::PushPayload.new(
|
305
|
-
platform: platform,
|
306
|
-
audience: audience,
|
307
|
-
notification: notification
|
308
|
-
).set_message(
|
309
|
-
msg_content,
|
310
|
-
title: title,
|
311
|
-
content_type: content_type,
|
312
|
-
extras: extras
|
313
|
-
).set_sms_message(content, delay_time).
|
314
|
-
set_options(options)
|
315
|
-
```
|
316
|
-
|
317
|
-
#### 推送消息
|
318
|
-
|
319
|
-
```ruby
|
320
|
-
# 仅接受一个 PushPayload 对象参数
|
321
|
-
pusher.push(push_payload)
|
322
|
-
```
|
323
|
-
|
324
|
-
#### 构建 SinglePushPayload 对象
|
325
|
-
|
326
|
-
一个单一目标的推送对象,目标为regId或者alias。用于批量单推接口,不同的目标指定不同的推送内容
|
327
|
-
|
328
|
-
```ruby
|
329
|
-
# 初始化 SinglePushPayload 对象
|
330
|
-
single_push_payload = Push::SinglePushPayload.new(
|
331
|
-
platform: platform,
|
332
|
-
target: target
|
333
|
-
)
|
334
|
-
```
|
335
|
-
|
336
|
-
参数说明
|
337
|
-
|
338
|
-
| 参数 | 是否必须 | 说明 |
|
339
|
-
| --- | :---: | --- |
|
340
|
-
| platform | 是 | 表示推送的平台,其可接受的参数为 'all'(表示推送到所有平台), 'android' 或 'ios' 或 ['android', 'ios'] |
|
341
|
-
| target | 是 | 推送设备指定。如果是调用RegID方式批量单推接口(/v3/push/batch/regid/single),那此处就是指定regid值;如果是调用Alias方式批量单推接口(/v3/push/batch/alias/single),那此处就是指定alias值。 |
|
342
|
-
| notification | 否 | 通知内容体。是被推送到客户端的内容。与 message 一起二者必须有其一,可以二者并存 |
|
343
|
-
| message | 否 | 消息内容体。是被推送到客户端的内容。与 notification 一起二者必须有其一,可以二者并存 |
|
344
|
-
| sms_message | 否 | 短信渠道补充送达内容体 |
|
345
|
-
| options | 否 | 推送参数 |
|
346
|
-
|
347
|
-
#### 批量单推(VIP专属接口)
|
348
|
-
|
349
|
-
如果您在给每个用户的推送内容都不同的情况下,可以使用此接口。
|
350
|
-
|
351
|
-
```ruby
|
352
|
-
# 针对RegID方式批量单推
|
353
|
-
single_push_payload = Push::SinglePushPayload.new(
|
354
|
-
platform: platform,
|
355
|
-
target: target
|
356
|
-
)
|
357
|
-
@pusher.push_batch_regid([single_push_payload])
|
358
|
-
```
|
359
|
-
|
360
|
-
```ruby
|
361
|
-
# 针对Alias方式批量单推
|
362
|
-
single_push_payload = Push::SinglePushPayload.new(
|
363
|
-
platform: platform,
|
364
|
-
target: target
|
365
|
-
)
|
366
|
-
@pusher.push_batch_alias([single_push_payload])
|
367
|
-
```
|
368
|
-
|
369
|
-
## Report API
|
370
|
-
|
371
|
-
```ruby
|
372
|
-
reporter = jpush.reporter
|
373
|
-
```
|
374
|
-
|
375
|
-
#### 送达统计(旧)
|
376
|
-
|
377
|
-
```ruby
|
378
|
-
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
379
|
-
reporter.received(msg_ids)
|
380
|
-
```
|
381
|
-
|
382
|
-
#### 送达统计详情(新)
|
383
|
-
|
384
|
-
```ruby
|
385
|
-
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
386
|
-
reporter.received_detail(msg_ids)
|
387
|
-
```
|
388
|
-
|
389
|
-
#### 送达状态查询
|
390
|
-
|
391
|
-
```ruby
|
392
|
-
# 参数 msg_id 为消息ID,registration_ids为一个注册ID数组
|
393
|
-
reporter.status_message(
|
394
|
-
msg_id: msg_id,
|
395
|
-
registration_ids:
|
396
|
-
date: date
|
397
|
-
)
|
398
|
-
```
|
399
|
-
|
400
|
-
参数说明
|
401
|
-
|
402
|
-
| 参数 | 是否必须 | 说明 |
|
403
|
-
| --- | :---: | --- |
|
404
|
-
| msg_id | 是 | 消息 id,一次调用仅支持一个消息 id 查询。 |
|
405
|
-
| registration_ids | 是 | JSON Array 类型,多个registration id 用逗号隔开,一次调用最多支持 1000个。 |
|
406
|
-
| date | 否 | 查询的指定日期,格式为 yyyy-mm-dd,默认为当天。 |
|
407
|
-
|
408
|
-
#### 消息统计(VIP专属接口,旧)
|
409
|
-
|
410
|
-
```ruby
|
411
|
-
# 与送达统计 API 不同的是,该 API 提供更多的的统计数据
|
412
|
-
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
413
|
-
reporter.messages(msg_ids)
|
414
|
-
```
|
415
|
-
|
416
|
-
#### 消息统计详情(VIP 专属接口,新)
|
417
|
-
|
418
|
-
```ruby
|
419
|
-
# 与“送达统计” API 不同的是,该 API 提供更多的针对一个 msgid 的统计数据。
|
420
|
-
# 与“消息统计” 旧接口相比,此接口获取到的数据更详细,而且如果您的应用开通了Android厂商通道,建议使用此接口。
|
421
|
-
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
422
|
-
reporter.messages_detail(msg_ids)
|
423
|
-
```
|
424
|
-
|
425
|
-
#### 用户统计(VIP专属接口)
|
426
|
-
|
427
|
-
```ruby
|
428
|
-
# 提供近2个月内某时间段的用户相关统计数据:新增用户、在线用户、活跃用户
|
429
|
-
reporter.users(time_unit, start, duration)
|
430
|
-
```
|
431
|
-
|
432
|
-
参数说明
|
433
|
-
|
434
|
-
| 参数 | 是否必须 | 说明 |
|
435
|
-
| --- | :---: | --- |
|
436
|
-
| time_unit | 是 | 表示时间单位,支持:HOUR(小时)、DAY(天)、MONTH(月) (不区分大小写) |
|
437
|
-
| start | 是 | 接受一个 Time 类的实例,表示统计的起始时间,会根据参数 time_unit 自动的转换成需要的格式。若 time_unit 为 'MONTH' 其格式为yyyy-mm,若 time_unit 为 'DAY' 其格式为 yyyy-mm-dd,若 time_unit 为 'MONTH',其格式为 yyyy-mm-dd hh,也就是说,会自动根据 time_unit 的不同将 Time 类的实例中用不到的部分去掉 |
|
438
|
-
| duration | 是 | 表示统计持续的时长,根据参数 time_unit 的不同有不同的取值范围,若 time_unit 为 'MONTH' 其范围为1至2,若 time_unit 为 'DAY' 其范围为1至60,若 time_unit 为 'HOUR',其范围为1至24,并且只支持输出当天的统计结果,若 duration 超过限定的最大取值,则取最大值。 |
|
439
|
-
|
440
|
-
## Schedule API
|
441
|
-
|
442
|
-
```ruby
|
443
|
-
schedules = jpush.schedules
|
444
|
-
```
|
445
|
-
|
446
|
-
#### 构建 Trigger 对象
|
447
|
-
|
448
|
-
表示 schedule 任务的触发条件,当前只支持定时任务(single)或定期任务(periodical)
|
449
|
-
|
450
|
-
###### 定时任务(single)
|
451
|
-
|
452
|
-
```ruby
|
453
|
-
# 参数 time 接受一个 Time 类的实例
|
454
|
-
single = JPush::Schedule::Trigger.new.set_single(time)
|
455
|
-
```
|
456
|
-
|
457
|
-
###### 定期任务(periodical)
|
458
|
-
|
459
|
-
```ruby
|
460
|
-
periodical = JPush::Schedule::Trigger.new.set_periodical(start_time, end_time, time, time_unit, frequency, point)
|
461
|
-
```
|
462
|
-
|
463
|
-
参数说明
|
464
|
-
|
465
|
-
| 参数 | 是否必须 | 说明 |
|
466
|
-
| --- | :---: | --- |
|
467
|
-
| start_time | 是 | 表示定期任务有效起始时间,接受一个 Time 类的实例 |
|
468
|
-
| end_time | 是 | 表示定期任务有效过期时间,接受一个 Time 类的实例 |
|
469
|
-
| time | 是 | 表示触发定期任务的定期执行时间, 其接受一个表示24小时制时间(时分秒)的字符串,例如:'12:07' |
|
470
|
-
| time_unit | 是 | 表示定期任务的执行的最小时间单位 可选 'day','week' 或 'month' |
|
471
|
-
| frequency | 是 | 与 time_unit 的乘积共同表示的定期任务的执行周期 |
|
472
|
-
| point | 是 | 接受一个数组,此项与 time_unit 相对应:当 time_unit 为 day 时 point 此项无效;当 time_unit 为 week 时,point 为数组 ['MON','TUE','WED','THU','FRI','SAT','SUN'] 的子数组,表示星期几进行触发;当 time_unit 为 month 时,point 为当前进行月对应的日期, 为数组 ['01', '02' , .., '31'] 的子数组 |
|
473
|
-
|
474
|
-
#### 构建 SchedulePayload 对象
|
475
|
-
|
476
|
-
```ruby
|
477
|
-
# 参数 trigger 接受一个 Trigger 对象,或者一个 Time 对象快速设置 single 定时任务
|
478
|
-
# 参数 push_payload 仅接受一个有效的 PushPayload 对象
|
479
|
-
JPush::Schedule::SchedulePayload.new(name, trigger, push_payload)
|
480
|
-
```
|
481
|
-
|
482
|
-
#### 创建定时任务
|
483
|
-
|
484
|
-
```ruby
|
485
|
-
# 参数 schedule_payload 仅接受一个有效的 SchedulePayload 对象
|
486
|
-
schedules.create(schedule_payload)
|
487
|
-
```
|
488
|
-
|
489
|
-
#### 获取有效的定时任务列表
|
490
|
-
|
491
|
-
```ruby
|
492
|
-
# 返回当前请求页的详细的 schedule-task 列表,如未指定page则page为1
|
493
|
-
schedules.tasks(page)
|
494
|
-
```
|
495
|
-
|
496
|
-
#### 获取定时任务详情
|
497
|
-
|
498
|
-
```ruby
|
499
|
-
schedules.show(schedule_id)
|
500
|
-
```
|
501
|
-
|
502
|
-
#### 更新定时任务
|
503
|
-
|
504
|
-
**更新操作必须为 'name','enabled','trigger' 或 'push' 四项中的一项或多项**
|
505
|
-
|
506
|
-
**定时任务(single)与定期任务(periodical)之间不能进行相互更新,即,原先为single类任务,则不能更新为periodical任务,反之亦然**
|
507
|
-
|
508
|
-
**不能更新已过期的schedule任务**
|
509
|
-
|
510
|
-
```ruby
|
511
|
-
schedules.update(schedule_id, name: name, enabled: enabled, trigger: trigger, push: push_payload)
|
512
|
-
# 例如只更新 name
|
513
|
-
schedules.update(schedule_id, name: 'jpush')
|
514
|
-
```
|
515
|
-
|
516
|
-
参数说明
|
517
|
-
|
518
|
-
| 参数 | 是否必须 | 说明 |
|
519
|
-
| --- | :---: | --- |
|
520
|
-
| schedule_id | 是 | 表示要更新的定时任务的 id |
|
521
|
-
| name | 否 | 表示定时任务的名字 |
|
522
|
-
| enabled | 否 | 表示任务当前状态,布尔值,必须为 true 或 false |
|
523
|
-
| trigger | 否 | 接受一个 Trigger 对象,或者一个 Time 对象快速设置 single 定时任务 |
|
524
|
-
| push_payload | 否 | 仅接受一个有效的 PushPayload 对象 |
|
525
|
-
|
526
|
-
#### 删除定时任务
|
527
|
-
|
528
|
-
```ruby
|
529
|
-
schedules.delete(schedule_id)
|
530
|
-
```
|
531
|
-
|
532
|
-
## Device API
|
533
|
-
|
534
|
-
Device API 用于在服务器端查询、设置、更新、删除设备的 tag,alias 信息,使用时需要注意不要让服务端设置的标签又被客户端给覆盖了
|
535
|
-
|
536
|
-
```ruby
|
537
|
-
devices = jpush.devices
|
538
|
-
tags = jpush.tags
|
539
|
-
aliases = jpush.aliases
|
540
|
-
```
|
541
|
-
|
542
|
-
#### 查询设备 (设备的别名与标签)
|
543
|
-
|
544
|
-
```ruby
|
545
|
-
# 获取当前设备的所有属性,包含标签 tags, 别名 alias, 手机号码 mobile
|
546
|
-
devices.show(registration_id)
|
547
|
-
```
|
548
|
-
|
549
|
-
#### 更新设备 (设备的别名与标签)
|
550
|
-
|
551
|
-
```ruby
|
552
|
-
# 为设备添加/移除标签
|
553
|
-
# 参数 tags 为一个表示有效的 tag 字符串或者一个最多包含100个有效的 tag 字符串的数组
|
554
|
-
devices.add_tags(registration_id, tags)
|
555
|
-
devices.remove_tags(registration_id, tags)
|
556
|
-
|
557
|
-
# 清除设备所有标签
|
558
|
-
devices.clear_tags(registration_id)
|
559
|
-
|
560
|
-
# 更新设备的别名
|
561
|
-
devices.update_alias(registration_id, alis)
|
562
|
-
|
563
|
-
# 删除设备的别名
|
564
|
-
devices.delete_alias(registration_id)
|
565
|
-
|
566
|
-
# 更新设备的手机号码
|
567
|
-
devices.update_mobile(registration_id)
|
568
|
-
```
|
569
|
-
|
570
|
-
#### 获取用户在线状态(VIP专属接口)
|
571
|
-
|
572
|
-
```ruby
|
573
|
-
# 参数 registration_ids 为一个表示有效的 registration_id 字符串或者一个最多包含1000个有效的 registration_id 字符串的数组
|
574
|
-
device.status(registration_ids)
|
575
|
-
```
|
576
|
-
|
577
|
-
#### 查询标签列表
|
578
|
-
|
579
|
-
```ruby
|
580
|
-
# 获取应用的所有标签列表
|
581
|
-
tags.list
|
582
|
-
```
|
583
|
-
|
584
|
-
#### 判断设备与标签的绑定
|
585
|
-
|
586
|
-
```ruby
|
587
|
-
# 查询某个设备是否在标签下
|
588
|
-
tags.has_device?(tag_value, registration_id)
|
589
|
-
```
|
590
|
-
|
591
|
-
#### 更新标签 (与设备的绑定的关系)
|
592
|
-
|
593
|
-
```ruby
|
594
|
-
# 为一个标签添加/移除设备
|
595
|
-
# 参数 registration_ids 为一个表示有效的 registration_id 字符串或者一个最多包含1000个有效的 registration_id 字符串的数组
|
596
|
-
tags.add_devices(tag_value, registration_ids)
|
597
|
-
tags.remove_devices(tag_value, registration_ids)
|
598
|
-
```
|
599
|
-
|
600
|
-
#### 删除标签 (与设备的绑定关系)
|
601
|
-
|
602
|
-
```ruby
|
603
|
-
# 删除一个标签,以及标签与设备之间的关联关系, platform 不填默认为所有平台
|
604
|
-
tags.delete(tag_value, platform)
|
605
|
-
```
|
606
|
-
|
607
|
-
#### 查询别名 (与设备的绑定关系)
|
608
|
-
|
609
|
-
```ruby
|
610
|
-
# 获取指定别名下的设备,最多输出10个, platform 不填默认为所有平台
|
611
|
-
aliases.show(alias_value, platform)
|
612
|
-
```
|
613
|
-
|
614
|
-
#### 删除别名 (与设备的绑定关系)
|
615
|
-
|
616
|
-
```ruby
|
617
|
-
# 删除一个别名,以及该别名与设备的绑定关系, platform 不填默认为所有平台
|
618
|
-
aliases.delete(alias_value, platform)
|
619
|
-
```
|
1
|
+
# 目录
|
2
|
+
|
3
|
+
- [Getting Started](#getting-started)
|
4
|
+
- [Push API](#push-api)
|
5
|
+
- [构建 Audience 对象](#构建-audience-对象)
|
6
|
+
- [构建 Notification 对象](#构建-notification-对象)
|
7
|
+
- [构建 PushPayload 对象](#构建-pushpayload-对象)
|
8
|
+
- [推送消息](#推送消息)
|
9
|
+
- [构建 SinglePushPayload 对象](#构建-SinglePushPayload-对象)
|
10
|
+
- [批量单推(VIP专属接口)](#批量单推vip专属接口)
|
11
|
+
- [Report API](#report-api)
|
12
|
+
- [送达统计(旧)](#送达统计旧)
|
13
|
+
- [送达统计详情(新)](#送达统计详情新)
|
14
|
+
- [送达状态查询](#送达状态查询)
|
15
|
+
- [消息统计(VIP专属接口,旧)](#消息统计vip专属接口旧)
|
16
|
+
- [消息统计详情(VIP 专属接口,新)](#消息统计详情vip-专属接口新)
|
17
|
+
- [用户统计(VIP专属接口)](#用户统计vip专属接口)
|
18
|
+
- [Schedule API](#schedule-api)
|
19
|
+
- [构建 Trigger 对象](#构建-trigger-对象)
|
20
|
+
- [构建 SchedulePayload 对象](#构建-schedulepayload-对象)
|
21
|
+
- [创建定时任务](#创建定时任务)
|
22
|
+
- [获取有效的定时任务列表](#获取有效的定时任务列表)
|
23
|
+
- [获取定时任务详情](#获取定时任务详情)
|
24
|
+
- [更新定时任务](#更新定时任务)
|
25
|
+
- [删除定时任务](#删除定时任务)
|
26
|
+
- [Device API](#device-api)
|
27
|
+
- [查询设备](#查询设备-设备的别名与标签)
|
28
|
+
- [更新设备](#更新设备-设备的别名与标签)
|
29
|
+
- [获取用户在线状态(VIP专属接口)](#获取用户在线状态vip专属接口)
|
30
|
+
- [查询标签列表](#查询标签列表)
|
31
|
+
- [判断设备与标签的绑定](#判断设备与标签的绑定)
|
32
|
+
- [更新标签](#更新标签-与设备的绑定的关系)
|
33
|
+
- [删除标签](#删除标签-与设备的绑定关系)
|
34
|
+
- [查询别名](#查询别名-与设备的绑定关系)
|
35
|
+
- [删除别名](#删除别名-与设备的绑定关系)
|
36
|
+
|
37
|
+
## Getting Started
|
38
|
+
|
39
|
+
[Where to get app_key or master_secret?](https://www.jpush.cn/common/apps/new)
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
app_key = 'xxx'
|
43
|
+
master_secret = 'xxx'
|
44
|
+
jpush = JPush::Client.new(app_key, master_secret)
|
45
|
+
```
|
46
|
+
|
47
|
+
## Push API
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
pusher = jpush.pusher
|
51
|
+
|
52
|
+
# simplest push Hello to all
|
53
|
+
push_payload = JPush::Push::PushPayload.new(
|
54
|
+
platform: 'all',
|
55
|
+
audience: 'all',
|
56
|
+
notification: 'hello jpush',
|
57
|
+
message: 'hello world'
|
58
|
+
)
|
59
|
+
pusher.push(push_payload)
|
60
|
+
```
|
61
|
+
|
62
|
+
#### 构建 Audience 对象
|
63
|
+
|
64
|
+
推送设备对象,表示一条推送可以被推送到哪些设备列表。
|
65
|
+
如果要发广播(全部设备),不需要构建 Audience 对象,在新建 PushPayload 对象的时候,给 'audience' 参数直接传递字符串 'all' 即可。
|
66
|
+
广播外的设备选择方式,有4种类型: tag, tag_and, tag_not, alias, registration_id, **5 种类型至少需要有其一, 这几种类型并存时多项的隐含关系是 AND,即取交集**
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
audience = JPush::Push::Audience.new
|
70
|
+
audience.set_tag(tag)
|
71
|
+
audience.set_tag_and(tag_and)
|
72
|
+
audience.set_tag_not(tag_not)
|
73
|
+
audience.set_alias(alis)
|
74
|
+
audience.set_registration_id(registration_ids)
|
75
|
+
|
76
|
+
# 链式调用
|
77
|
+
audience = JPush::Push::Audience.new.
|
78
|
+
set_tag(tag).
|
79
|
+
set_tag_and(tag_and).
|
80
|
+
set_tag_not(tag_not).
|
81
|
+
set_alias(alis).
|
82
|
+
set_registration_id(registration_ids)
|
83
|
+
```
|
84
|
+
|
85
|
+
参数说明
|
86
|
+
|
87
|
+
| 参数 | 是否必须 | 说明 |
|
88
|
+
| --- | :---: | --- |
|
89
|
+
| tag | 否 | 有效的标签字符串或者一个最多包含20个有效的标签字符串的数组 |
|
90
|
+
| tag_and | 否 | 有效的标签字符串或者一个最多包含20个有效的标签字符串的数组 |
|
91
|
+
| tag_not | 否 | 有效的标签字符串或者一个最多包含20个有效的标签字符串的数组 |
|
92
|
+
| alis | 否 | 有效的别名字符串或者一个最多包含1000个有效的别名字符串的数组 |
|
93
|
+
| registration_ids | 否 | 有效的 registration id 字符串或者一个最多包含1000个有效的 registration id 字符串的数组 |
|
94
|
+
|
95
|
+
#### 构建 Notification 对象
|
96
|
+
|
97
|
+
若通知的内容在各个平台上,都只有 'alert' 这一个最基本的属性,
|
98
|
+
则不需要构建 Notifacation 对象,在新建 PushPayload 对象的时候,给 'notication' 参数直接传递表示 alert 的字符串即可,
|
99
|
+
也可以在 Notifacation 对象中设置 alert 属性。另外 IOS 的 alert 还支持 Hash 对象的参数。
|
100
|
+
其下属属性包含3种,2个平台属性,以及一个 'alert' 属性。
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
notification = JPush::Push::Notification.new
|
104
|
+
```
|
105
|
+
|
106
|
+
###### alert
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
notification.set_alert(alert)
|
110
|
+
```
|
111
|
+
|
112
|
+
###### android
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
notification.set_android(
|
116
|
+
alert: alert,
|
117
|
+
title: title,
|
118
|
+
builder_id: builder_id,
|
119
|
+
channel_id: channel_id,
|
120
|
+
extras: extras
|
121
|
+
)
|
122
|
+
```
|
123
|
+
|
124
|
+
参数说明
|
125
|
+
|
126
|
+
| 参数 | 是否必须 | 说明 |
|
127
|
+
| --- | :---: | --- |
|
128
|
+
| alert | 是 | 表示通知内容,会覆盖上级统一指定的 alert 信息;内容可以为空字符串,表示不展示到通知栏 |
|
129
|
+
| title | 否 | 表示通知标题,会替换通知里原来展示 App 名称的地方 |
|
130
|
+
| builder_id | 否 | 表示通知栏样式 ID,Android SDK 可设置通知栏样式,这里根据样式 ID 来指定该使用哪套样式 |
|
131
|
+
| channel_id | 否 | 不超过1000字节,Android 8.0开始可以进行NotificationChannel配置,这里根据channel ID 来指定通知栏展示效果。 |
|
132
|
+
| priority | 否 | 表示通知栏展示优先级,默认为 0,范围为 -2~2 ,其他值将会被忽略而采用默认值 |
|
133
|
+
| category | 否 | 表示通知栏条目过滤或排序,完全依赖 rom 厂商对 category 的处理策略 |
|
134
|
+
| style | 否 | 表示通知栏样式类型,默认为 0,还有1,2,3 可选,用来指定选择哪种通知栏样式,其他值无效。有三种可选分别为 bigText = 1,Inbox = 2,bigPicture = 3 |
|
135
|
+
| alert_type | 否 | 表示通知提醒方式, 可选范围为 -1~7 ,对应 Notification.DEFAULT_ALL = -1 或者 Notification.DEFAULT_SOUND = 1, Notification.DEFAULT_VIBRATE = 2, Notification.DEFAULT_LIGHTS = 4 的任意 “or” 组合。默认按照 -1 处理。 |
|
136
|
+
| big_text | 否 | 表示大文本通知栏样式,当 style = 1 时可用,内容会被通知栏以大文本的形式展示出来,支持 api 16 以上的 rom |
|
137
|
+
| inbox | 否 | 表示文本条目通知栏样式,接受一个数组,当 style = 2 时可用,数组的每个 key 对应的 value 会被当作文本条目逐条展示,支持 api 16 以上的 rom |
|
138
|
+
| big_pic_path | 否 | 表示大图片通知栏样式,当 style = 3 时可用,可以是网络图片 url,或本地图片的 path,目前支持 .jpg 和 .png 后缀的图片。图片内容会被通知栏以大图片的形式展示出来。如果是 http/https 的 url,会自动下载;如果要指定开发者准备的本地图片就填 sdcard 的相对路径,支持 api 16 以上的 rom |
|
139
|
+
| extras | 否 | 表示扩展字段,接受一个 Hash 对象,以供业务使用 |
|
140
|
+
|
141
|
+
###### ios
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
notification.set_ios(
|
145
|
+
alert: alert,
|
146
|
+
sound: sound,
|
147
|
+
badge: badge,
|
148
|
+
contentavailable: contentavailable,
|
149
|
+
mutablecontent: mutablecontent,
|
150
|
+
category: category,
|
151
|
+
extras: extras
|
152
|
+
)
|
153
|
+
```
|
154
|
+
|
155
|
+
参数说明
|
156
|
+
|
157
|
+
| 参数 | 是否必须 | 说明 |
|
158
|
+
| --- | :---: | --- |
|
159
|
+
| alert | 是 | 表示通知内容,会覆盖上级统一指定的 alert 信息;内容可以为空字符串,表示不展示到通知栏 |
|
160
|
+
| sound | 否 | 表示通知提示声音 |
|
161
|
+
| badge | 否 | 表示应用角标,把角标数字改为指定的数字;为 0 表示清除,若不填默认是默认是 +1 |
|
162
|
+
| contentavailable | 否 | 表示推送唤醒,仅接受 true 表示为 Background Remote Notification,若不填默认是 nil 表示普通的 Remote Notification |
|
163
|
+
| mutablecontent | 否 | 表示通知扩展,仅接受 true 表示支持 iOS10 的 UNNotificationServiceExtension,若不填默认是 nil 表示普通的 Remote Notification |
|
164
|
+
| category | 否 | IOS8才支持。设置 APNs payload 中的 'category' 字段值 |
|
165
|
+
| extras | 否 | 表示扩展字段,接受一个 Hash 对象,以供业务使用 |
|
166
|
+
|
167
|
+
###### 链式调用
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
notification = JPush::Push::Notification.new.
|
171
|
+
set_alert(alert).
|
172
|
+
set_android(
|
173
|
+
alert: alert,
|
174
|
+
title: title,
|
175
|
+
builder_id: builder_id,
|
176
|
+
extras: extras
|
177
|
+
).set_ios(
|
178
|
+
alert: alert,
|
179
|
+
sound: sound,
|
180
|
+
badge: badge,
|
181
|
+
contentavailable: contentavailable,
|
182
|
+
mutablecontent: mutablecontent,
|
183
|
+
category: category,
|
184
|
+
extras: extras
|
185
|
+
)
|
186
|
+
```
|
187
|
+
|
188
|
+
#### 构建 PushPayload 对象
|
189
|
+
|
190
|
+
一个推送对象,表示一条推送相关的所有信息,通知内容体。是被推送到客户端的内容。
|
191
|
+
**notification 和 message 二者必须有其一,可以二者并存。**
|
192
|
+
**如果目标平台有 iOS 平台 需要在 options 中通过 apns_production 字段来制定推送环境。True 表示推送生产环境,False 表示要推送开发环境; 如果不指定则为推送生产环境。**
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
# audience 和 notification 对象可按照上面的例子实例化
|
196
|
+
audience = JPush::Push::Andience.new.set_registration_id(registration_ids)
|
197
|
+
notification = JPush::Push::Notification.new.set_alert(alert)
|
198
|
+
```
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
# 初始化 PushPayload 对象
|
202
|
+
push_payload = JPush::Push::PushPayload.new(
|
203
|
+
platform: platform,
|
204
|
+
audience: audience,
|
205
|
+
notification: notification,
|
206
|
+
message: message
|
207
|
+
)
|
208
|
+
```
|
209
|
+
|
210
|
+
参数说明
|
211
|
+
|
212
|
+
| 参数 | 是否必须 | 说明 |
|
213
|
+
| --- | :---: | --- |
|
214
|
+
| platform | 是 | 表示推送的平台,其可接受的参数为 'all'(表示推送到所有平台), 'android' 或 'ios' 或 ['android', 'ios'] |
|
215
|
+
| audience | 是 | 表示推送的设备,其可接受的参数为 'all' (表示发广播,推送到全部设备) 或者一个 Audience 对象 |
|
216
|
+
| notification | 否 | 接受一个字符串快速设置最基本的 'alert' 属性,或者一个 Notifcation 对象 |
|
217
|
+
| message | 否 | 表示应用内消息,仅接受一个字符串来快速设置消息内容本身,要构建复杂的 Message 对象,需使用 PushPayload 的实例方法 set_message |
|
218
|
+
|
219
|
+
###### 添加应用内消息
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
push_payload = JPush::Push::PushPayload.new(
|
223
|
+
platform: platform,
|
224
|
+
audience: audience,
|
225
|
+
notification: notification,
|
226
|
+
).set_message(
|
227
|
+
msg_content,
|
228
|
+
title: title,
|
229
|
+
content_type: content_type,
|
230
|
+
extras: extras
|
231
|
+
)
|
232
|
+
```
|
233
|
+
|
234
|
+
参数说明
|
235
|
+
|
236
|
+
| 参数 | 是否必须 | 说明 |
|
237
|
+
| --- | :---: | --- |
|
238
|
+
| msg_content | 是 | 消息内容本身 |
|
239
|
+
| title | 否 | 消息标题 |
|
240
|
+
| content_type | 否 | 消息内容类型 |
|
241
|
+
| extras | 否 | 表示扩展字段,接受一个 Hash 对象,以供业务使用 |
|
242
|
+
|
243
|
+
###### 添加短信业务
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
push_payload = JPush::Push::PushPayload.new(
|
247
|
+
platform: platform,
|
248
|
+
audience: audience,
|
249
|
+
notification: notification
|
250
|
+
)
|
251
|
+
sms_message = {
|
252
|
+
delay_time: delay_time,
|
253
|
+
signid: signid,
|
254
|
+
temp_id: temp_id,
|
255
|
+
temp_para: temp_para,
|
256
|
+
active_filter: active_filter
|
257
|
+
}
|
258
|
+
push_payload.set_sms_message(sms_message)
|
259
|
+
```
|
260
|
+
|
261
|
+
参数说明
|
262
|
+
|
263
|
+
| 参数 | 是否必须 | 说明 |
|
264
|
+
| --- | :---: | --- |
|
265
|
+
| delay_time | 是 | 单位为秒,不能超过 24 小时。设置为 0,表示立即发送短信。该参数仅对 android 和 iOS 平台有效,Winphone 平台则会立即发送短信。 |
|
266
|
+
| signid | 否 | 签名ID,该字段为空则使用应用默认签名。 |
|
267
|
+
| temp_id | 是 | 短信补充的内容模板 ID。没有填写该字段即表示不使用短信补充功能。 |
|
268
|
+
| temp_para | 否 | 短信模板中的参数。 |
|
269
|
+
| active_filter | 否 | active_filter 字段用来控制是否对补发短信的用户进行活跃过滤,默认为 true ,做活跃过滤;为 false,则不做活跃过滤; |
|
270
|
+
|
271
|
+
###### 推送可选项
|
272
|
+
|
273
|
+
```ruby
|
274
|
+
options = {
|
275
|
+
sendno: no,
|
276
|
+
time_to_live: time,
|
277
|
+
override_msg_id: msg_id,
|
278
|
+
apns_production: true,
|
279
|
+
big_push_duration: duration
|
280
|
+
}
|
281
|
+
|
282
|
+
# 参数 options 仅接受一个 Hash 对象,而这个 Hash 对象的键也仅支持上面所示的5种。
|
283
|
+
push_payload = JPush::Push::PushPayload.new(
|
284
|
+
platform: platform,
|
285
|
+
audience: audience,
|
286
|
+
notification: notification,
|
287
|
+
message: message
|
288
|
+
).set_options(options)
|
289
|
+
```
|
290
|
+
|
291
|
+
参数说明
|
292
|
+
|
293
|
+
| 可选项 | 说明 |
|
294
|
+
| --- | --- |
|
295
|
+
| sendno | 表示推送序号,纯粹用来作为 API 调用标识,API 返回时被原样返回,以方便 API 调用方匹配请求与返回 |
|
296
|
+
| time_to_live | 表示离线消息保留时长(秒),推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到 |
|
297
|
+
| override_msg_id | 表示要覆盖的消息ID |
|
298
|
+
| apns_production | 表示APNs是否生产环境,True 表示推送生产环境,False 表示要推送开发环境;如果不指定则为推送开发环境 |
|
299
|
+
| big_push_duration | 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,给定的n分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送 |
|
300
|
+
|
301
|
+
###### 链式调用
|
302
|
+
|
303
|
+
```ruby
|
304
|
+
push_payload = JPush::Push::PushPayload.new(
|
305
|
+
platform: platform,
|
306
|
+
audience: audience,
|
307
|
+
notification: notification
|
308
|
+
).set_message(
|
309
|
+
msg_content,
|
310
|
+
title: title,
|
311
|
+
content_type: content_type,
|
312
|
+
extras: extras
|
313
|
+
).set_sms_message(content, delay_time).
|
314
|
+
set_options(options)
|
315
|
+
```
|
316
|
+
|
317
|
+
#### 推送消息
|
318
|
+
|
319
|
+
```ruby
|
320
|
+
# 仅接受一个 PushPayload 对象参数
|
321
|
+
pusher.push(push_payload)
|
322
|
+
```
|
323
|
+
|
324
|
+
#### 构建 SinglePushPayload 对象
|
325
|
+
|
326
|
+
一个单一目标的推送对象,目标为regId或者alias。用于批量单推接口,不同的目标指定不同的推送内容
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
# 初始化 SinglePushPayload 对象
|
330
|
+
single_push_payload = Push::SinglePushPayload.new(
|
331
|
+
platform: platform,
|
332
|
+
target: target
|
333
|
+
)
|
334
|
+
```
|
335
|
+
|
336
|
+
参数说明
|
337
|
+
|
338
|
+
| 参数 | 是否必须 | 说明 |
|
339
|
+
| --- | :---: | --- |
|
340
|
+
| platform | 是 | 表示推送的平台,其可接受的参数为 'all'(表示推送到所有平台), 'android' 或 'ios' 或 ['android', 'ios'] |
|
341
|
+
| target | 是 | 推送设备指定。如果是调用RegID方式批量单推接口(/v3/push/batch/regid/single),那此处就是指定regid值;如果是调用Alias方式批量单推接口(/v3/push/batch/alias/single),那此处就是指定alias值。 |
|
342
|
+
| notification | 否 | 通知内容体。是被推送到客户端的内容。与 message 一起二者必须有其一,可以二者并存 |
|
343
|
+
| message | 否 | 消息内容体。是被推送到客户端的内容。与 notification 一起二者必须有其一,可以二者并存 |
|
344
|
+
| sms_message | 否 | 短信渠道补充送达内容体 |
|
345
|
+
| options | 否 | 推送参数 |
|
346
|
+
|
347
|
+
#### 批量单推(VIP专属接口)
|
348
|
+
|
349
|
+
如果您在给每个用户的推送内容都不同的情况下,可以使用此接口。
|
350
|
+
|
351
|
+
```ruby
|
352
|
+
# 针对RegID方式批量单推
|
353
|
+
single_push_payload = Push::SinglePushPayload.new(
|
354
|
+
platform: platform,
|
355
|
+
target: target
|
356
|
+
)
|
357
|
+
@pusher.push_batch_regid([single_push_payload])
|
358
|
+
```
|
359
|
+
|
360
|
+
```ruby
|
361
|
+
# 针对Alias方式批量单推
|
362
|
+
single_push_payload = Push::SinglePushPayload.new(
|
363
|
+
platform: platform,
|
364
|
+
target: target
|
365
|
+
)
|
366
|
+
@pusher.push_batch_alias([single_push_payload])
|
367
|
+
```
|
368
|
+
|
369
|
+
## Report API
|
370
|
+
|
371
|
+
```ruby
|
372
|
+
reporter = jpush.reporter
|
373
|
+
```
|
374
|
+
|
375
|
+
#### 送达统计(旧)
|
376
|
+
|
377
|
+
```ruby
|
378
|
+
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
379
|
+
reporter.received(msg_ids)
|
380
|
+
```
|
381
|
+
|
382
|
+
#### 送达统计详情(新)
|
383
|
+
|
384
|
+
```ruby
|
385
|
+
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
386
|
+
reporter.received_detail(msg_ids)
|
387
|
+
```
|
388
|
+
|
389
|
+
#### 送达状态查询
|
390
|
+
|
391
|
+
```ruby
|
392
|
+
# 参数 msg_id 为消息ID,registration_ids为一个注册ID数组
|
393
|
+
reporter.status_message(
|
394
|
+
msg_id: msg_id,
|
395
|
+
registration_ids:
|
396
|
+
date: date
|
397
|
+
)
|
398
|
+
```
|
399
|
+
|
400
|
+
参数说明
|
401
|
+
|
402
|
+
| 参数 | 是否必须 | 说明 |
|
403
|
+
| --- | :---: | --- |
|
404
|
+
| msg_id | 是 | 消息 id,一次调用仅支持一个消息 id 查询。 |
|
405
|
+
| registration_ids | 是 | JSON Array 类型,多个registration id 用逗号隔开,一次调用最多支持 1000个。 |
|
406
|
+
| date | 否 | 查询的指定日期,格式为 yyyy-mm-dd,默认为当天。 |
|
407
|
+
|
408
|
+
#### 消息统计(VIP专属接口,旧)
|
409
|
+
|
410
|
+
```ruby
|
411
|
+
# 与送达统计 API 不同的是,该 API 提供更多的的统计数据
|
412
|
+
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
413
|
+
reporter.messages(msg_ids)
|
414
|
+
```
|
415
|
+
|
416
|
+
#### 消息统计详情(VIP 专属接口,新)
|
417
|
+
|
418
|
+
```ruby
|
419
|
+
# 与“送达统计” API 不同的是,该 API 提供更多的针对一个 msgid 的统计数据。
|
420
|
+
# 与“消息统计” 旧接口相比,此接口获取到的数据更详细,而且如果您的应用开通了Android厂商通道,建议使用此接口。
|
421
|
+
# 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
|
422
|
+
reporter.messages_detail(msg_ids)
|
423
|
+
```
|
424
|
+
|
425
|
+
#### 用户统计(VIP专属接口)
|
426
|
+
|
427
|
+
```ruby
|
428
|
+
# 提供近2个月内某时间段的用户相关统计数据:新增用户、在线用户、活跃用户
|
429
|
+
reporter.users(time_unit, start, duration)
|
430
|
+
```
|
431
|
+
|
432
|
+
参数说明
|
433
|
+
|
434
|
+
| 参数 | 是否必须 | 说明 |
|
435
|
+
| --- | :---: | --- |
|
436
|
+
| time_unit | 是 | 表示时间单位,支持:HOUR(小时)、DAY(天)、MONTH(月) (不区分大小写) |
|
437
|
+
| start | 是 | 接受一个 Time 类的实例,表示统计的起始时间,会根据参数 time_unit 自动的转换成需要的格式。若 time_unit 为 'MONTH' 其格式为yyyy-mm,若 time_unit 为 'DAY' 其格式为 yyyy-mm-dd,若 time_unit 为 'MONTH',其格式为 yyyy-mm-dd hh,也就是说,会自动根据 time_unit 的不同将 Time 类的实例中用不到的部分去掉 |
|
438
|
+
| duration | 是 | 表示统计持续的时长,根据参数 time_unit 的不同有不同的取值范围,若 time_unit 为 'MONTH' 其范围为1至2,若 time_unit 为 'DAY' 其范围为1至60,若 time_unit 为 'HOUR',其范围为1至24,并且只支持输出当天的统计结果,若 duration 超过限定的最大取值,则取最大值。 |
|
439
|
+
|
440
|
+
## Schedule API
|
441
|
+
|
442
|
+
```ruby
|
443
|
+
schedules = jpush.schedules
|
444
|
+
```
|
445
|
+
|
446
|
+
#### 构建 Trigger 对象
|
447
|
+
|
448
|
+
表示 schedule 任务的触发条件,当前只支持定时任务(single)或定期任务(periodical)
|
449
|
+
|
450
|
+
###### 定时任务(single)
|
451
|
+
|
452
|
+
```ruby
|
453
|
+
# 参数 time 接受一个 Time 类的实例
|
454
|
+
single = JPush::Schedule::Trigger.new.set_single(time)
|
455
|
+
```
|
456
|
+
|
457
|
+
###### 定期任务(periodical)
|
458
|
+
|
459
|
+
```ruby
|
460
|
+
periodical = JPush::Schedule::Trigger.new.set_periodical(start_time, end_time, time, time_unit, frequency, point)
|
461
|
+
```
|
462
|
+
|
463
|
+
参数说明
|
464
|
+
|
465
|
+
| 参数 | 是否必须 | 说明 |
|
466
|
+
| --- | :---: | --- |
|
467
|
+
| start_time | 是 | 表示定期任务有效起始时间,接受一个 Time 类的实例 |
|
468
|
+
| end_time | 是 | 表示定期任务有效过期时间,接受一个 Time 类的实例 |
|
469
|
+
| time | 是 | 表示触发定期任务的定期执行时间, 其接受一个表示24小时制时间(时分秒)的字符串,例如:'12:07' |
|
470
|
+
| time_unit | 是 | 表示定期任务的执行的最小时间单位 可选 'day','week' 或 'month' |
|
471
|
+
| frequency | 是 | 与 time_unit 的乘积共同表示的定期任务的执行周期 |
|
472
|
+
| point | 是 | 接受一个数组,此项与 time_unit 相对应:当 time_unit 为 day 时 point 此项无效;当 time_unit 为 week 时,point 为数组 ['MON','TUE','WED','THU','FRI','SAT','SUN'] 的子数组,表示星期几进行触发;当 time_unit 为 month 时,point 为当前进行月对应的日期, 为数组 ['01', '02' , .., '31'] 的子数组 |
|
473
|
+
|
474
|
+
#### 构建 SchedulePayload 对象
|
475
|
+
|
476
|
+
```ruby
|
477
|
+
# 参数 trigger 接受一个 Trigger 对象,或者一个 Time 对象快速设置 single 定时任务
|
478
|
+
# 参数 push_payload 仅接受一个有效的 PushPayload 对象
|
479
|
+
JPush::Schedule::SchedulePayload.new(name, trigger, push_payload)
|
480
|
+
```
|
481
|
+
|
482
|
+
#### 创建定时任务
|
483
|
+
|
484
|
+
```ruby
|
485
|
+
# 参数 schedule_payload 仅接受一个有效的 SchedulePayload 对象
|
486
|
+
schedules.create(schedule_payload)
|
487
|
+
```
|
488
|
+
|
489
|
+
#### 获取有效的定时任务列表
|
490
|
+
|
491
|
+
```ruby
|
492
|
+
# 返回当前请求页的详细的 schedule-task 列表,如未指定page则page为1
|
493
|
+
schedules.tasks(page)
|
494
|
+
```
|
495
|
+
|
496
|
+
#### 获取定时任务详情
|
497
|
+
|
498
|
+
```ruby
|
499
|
+
schedules.show(schedule_id)
|
500
|
+
```
|
501
|
+
|
502
|
+
#### 更新定时任务
|
503
|
+
|
504
|
+
**更新操作必须为 'name','enabled','trigger' 或 'push' 四项中的一项或多项**
|
505
|
+
|
506
|
+
**定时任务(single)与定期任务(periodical)之间不能进行相互更新,即,原先为single类任务,则不能更新为periodical任务,反之亦然**
|
507
|
+
|
508
|
+
**不能更新已过期的schedule任务**
|
509
|
+
|
510
|
+
```ruby
|
511
|
+
schedules.update(schedule_id, name: name, enabled: enabled, trigger: trigger, push: push_payload)
|
512
|
+
# 例如只更新 name
|
513
|
+
schedules.update(schedule_id, name: 'jpush')
|
514
|
+
```
|
515
|
+
|
516
|
+
参数说明
|
517
|
+
|
518
|
+
| 参数 | 是否必须 | 说明 |
|
519
|
+
| --- | :---: | --- |
|
520
|
+
| schedule_id | 是 | 表示要更新的定时任务的 id |
|
521
|
+
| name | 否 | 表示定时任务的名字 |
|
522
|
+
| enabled | 否 | 表示任务当前状态,布尔值,必须为 true 或 false |
|
523
|
+
| trigger | 否 | 接受一个 Trigger 对象,或者一个 Time 对象快速设置 single 定时任务 |
|
524
|
+
| push_payload | 否 | 仅接受一个有效的 PushPayload 对象 |
|
525
|
+
|
526
|
+
#### 删除定时任务
|
527
|
+
|
528
|
+
```ruby
|
529
|
+
schedules.delete(schedule_id)
|
530
|
+
```
|
531
|
+
|
532
|
+
## Device API
|
533
|
+
|
534
|
+
Device API 用于在服务器端查询、设置、更新、删除设备的 tag,alias 信息,使用时需要注意不要让服务端设置的标签又被客户端给覆盖了
|
535
|
+
|
536
|
+
```ruby
|
537
|
+
devices = jpush.devices
|
538
|
+
tags = jpush.tags
|
539
|
+
aliases = jpush.aliases
|
540
|
+
```
|
541
|
+
|
542
|
+
#### 查询设备 (设备的别名与标签)
|
543
|
+
|
544
|
+
```ruby
|
545
|
+
# 获取当前设备的所有属性,包含标签 tags, 别名 alias, 手机号码 mobile
|
546
|
+
devices.show(registration_id)
|
547
|
+
```
|
548
|
+
|
549
|
+
#### 更新设备 (设备的别名与标签)
|
550
|
+
|
551
|
+
```ruby
|
552
|
+
# 为设备添加/移除标签
|
553
|
+
# 参数 tags 为一个表示有效的 tag 字符串或者一个最多包含100个有效的 tag 字符串的数组
|
554
|
+
devices.add_tags(registration_id, tags)
|
555
|
+
devices.remove_tags(registration_id, tags)
|
556
|
+
|
557
|
+
# 清除设备所有标签
|
558
|
+
devices.clear_tags(registration_id)
|
559
|
+
|
560
|
+
# 更新设备的别名
|
561
|
+
devices.update_alias(registration_id, alis)
|
562
|
+
|
563
|
+
# 删除设备的别名
|
564
|
+
devices.delete_alias(registration_id)
|
565
|
+
|
566
|
+
# 更新设备的手机号码
|
567
|
+
devices.update_mobile(registration_id)
|
568
|
+
```
|
569
|
+
|
570
|
+
#### 获取用户在线状态(VIP专属接口)
|
571
|
+
|
572
|
+
```ruby
|
573
|
+
# 参数 registration_ids 为一个表示有效的 registration_id 字符串或者一个最多包含1000个有效的 registration_id 字符串的数组
|
574
|
+
device.status(registration_ids)
|
575
|
+
```
|
576
|
+
|
577
|
+
#### 查询标签列表
|
578
|
+
|
579
|
+
```ruby
|
580
|
+
# 获取应用的所有标签列表
|
581
|
+
tags.list
|
582
|
+
```
|
583
|
+
|
584
|
+
#### 判断设备与标签的绑定
|
585
|
+
|
586
|
+
```ruby
|
587
|
+
# 查询某个设备是否在标签下
|
588
|
+
tags.has_device?(tag_value, registration_id)
|
589
|
+
```
|
590
|
+
|
591
|
+
#### 更新标签 (与设备的绑定的关系)
|
592
|
+
|
593
|
+
```ruby
|
594
|
+
# 为一个标签添加/移除设备
|
595
|
+
# 参数 registration_ids 为一个表示有效的 registration_id 字符串或者一个最多包含1000个有效的 registration_id 字符串的数组
|
596
|
+
tags.add_devices(tag_value, registration_ids)
|
597
|
+
tags.remove_devices(tag_value, registration_ids)
|
598
|
+
```
|
599
|
+
|
600
|
+
#### 删除标签 (与设备的绑定关系)
|
601
|
+
|
602
|
+
```ruby
|
603
|
+
# 删除一个标签,以及标签与设备之间的关联关系, platform 不填默认为所有平台
|
604
|
+
tags.delete(tag_value, platform)
|
605
|
+
```
|
606
|
+
|
607
|
+
#### 查询别名 (与设备的绑定关系)
|
608
|
+
|
609
|
+
```ruby
|
610
|
+
# 获取指定别名下的设备,最多输出10个, platform 不填默认为所有平台
|
611
|
+
aliases.show(alias_value, platform)
|
612
|
+
```
|
613
|
+
|
614
|
+
#### 删除别名 (与设备的绑定关系)
|
615
|
+
|
616
|
+
```ruby
|
617
|
+
# 删除一个别名,以及该别名与设备的绑定关系, platform 不填默认为所有平台
|
618
|
+
aliases.delete(alias_value, platform)
|
619
|
+
```
|