Skip to content

Commit f2bde45

Browse files
author
Helperhaps
committed
don't know why i am doing this
1 parent 393d8f8 commit f2bde45

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ try {
9292

9393
## Examples
9494

95+
**注意: 这只是使用样例, 不应该直接用于实际环境中!!**
96+
9597
在下载的中的 [examples](https://github.com/jpush/jpush-api-php-client/tree/master/examples) 文件夹有简单示例代码, 开发者可以参考其中的样例快速了解该库的使用方法。
9698
> **注:所下载的样例代码不可马上使用,需要在 `examples/conf.php` 文件中填入相关的必要参数,或者设置相关环境变量,不进行这个操作则示例运行会失败**
9799

examples/push_example.php

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
// 这只是使用样例,不应该直接用于实际生产环境中 !!
23

34
require 'conf.php';
45

56
// 简单推送示例
7+
// 这只是使用样例,不应该直接用于实际生产环境中 !!
68

79
$push_payload = $client->push()
810
->setPlatform('all')
@@ -21,17 +23,23 @@
2123

2224

2325
// 完整的推送示例
26+
// 这只是使用样例,不应该直接用于实际生产环境中 !!
2427
try {
2528
$response = $client->push()
2629
->setPlatform(array('ios', 'android'))
27-
->addAlias('alias')
30+
// 一般情况下,关于 audience 的设置只需要调用 addAlias、addTag、addTagAnd 或 addRegistrationId
31+
// 这四个方法中的某一个即可,这里仅作为示例,当然全部调用也可以,多项 audience 调用表示其结果的交集
32+
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
33+
34+
// ->addAlias('alias')
2835
->addTag(array('tag1', 'tag2'))
29-
->addRegistrationId($registration_id)
36+
// ->addRegistrationId($registration_id)
37+
3038
->setNotificationAlert('Hi, JPush')
3139
->iosNotification('Hello IOS', array(
32-
'sound' => 'hello jpush',
33-
'badge' => 2,
34-
'content-available' => true,
40+
'sound' => 'sound.caf',
41+
// 'badge' => '+1',
42+
// 'content-available' => true,
3543
'category' => 'jiguang',
3644
'extras' => array(
3745
'key' => 'value',
@@ -40,27 +48,47 @@
4048
))
4149
->androidNotification('Hello Android', array(
4250
'title' => 'hello jpush',
43-
'build_id' => 2,
51+
// 'build_id' => 2,
4452
'extras' => array(
4553
'key' => 'value',
4654
'jiguang'
4755
),
4856
))
4957
->message('message content', array(
5058
'title' => 'hello jpush',
51-
'content_type' => 'text',
59+
// 'content_type' => 'text',
5260
'extras' => array(
5361
'key' => 'value',
5462
'jiguang'
5563
),
5664
))
5765
->options(array(
58-
'sendno' => 100,
59-
'time_to_live' => 100,
66+
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
67+
// API 返回时被原样返回,以方便 API 调用方匹配请求与返回
68+
// 这里设置为 100 仅作为示例
69+
70+
// 'sendno' => 100,
71+
72+
// time_to_live: 表示离线消息保留时长(秒),
73+
// 推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。
74+
// 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
75+
// 这里设置为 1 仅作为示例
76+
77+
// 'time_to_live' => 1,
78+
79+
// apns_production: 表示APNs是否生产环境,
80+
// True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送生产环境
81+
6082
'apns_production' => false,
61-
'big_push_duration' => 100
83+
84+
// big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
85+
// 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
86+
// 这里设置为 1 仅作为示例
87+
88+
// 'big_push_duration' => 1
6289
))
6390
->send();
91+
6492
} catch (\JPush\Exceptions\APIConnectionException $e) {
6593
// try something here
6694
print $e;

examples/schedule_example.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
// 这只是使用样例不应该直接用于实际生产环境中 !!
3+
24
require 'conf.php';
35

46
$payload = $client->push()

0 commit comments

Comments
 (0)