|
6 | 6 | use JPush\Client as JPush;
|
7 | 7 |
|
8 | 8 | // 这里填写appKey,masterSecret以及registration_id
|
9 |
| -$app_key = 'your AppKey'; |
10 |
| -$master_secret = 'your MasterSecret'; |
| 9 | +$app_key = 'e5c0d34f58732cf09b2d4d74'; |
| 10 | +$master_secret = '4cdda6d3c8b029941dbc5cb3'; |
11 | 11 | $registration_id = ('registration_id');
|
12 | 12 |
|
13 | 13 | $client = new JPush($app_key, $master_secret);
|
14 | 14 |
|
15 | 15 | // 简单推送示例
|
16 | 16 | // 这只是使用样例,不应该直接用于实际生产环境中 !!
|
17 | 17 |
|
18 |
| -$push_payload = $client->push() |
19 |
| - ->setPlatform('all') |
20 |
| - ->addAllAudience() |
21 |
| - ->setNotificationAlert('Hi, JPush'); |
22 |
| -try { |
23 |
| - $response = $push_payload->send(); |
24 |
| - print_r($response); |
25 |
| -} catch (\JPush\Exceptions\APIConnectionException $e) { |
26 |
| - // try something here |
27 |
| - print $e; |
28 |
| -} catch (\JPush\Exceptions\APIRequestException $e) { |
29 |
| - // try something here |
30 |
| - print $e; |
31 |
| -} |
| 18 | +// $push_payload = $client->push() |
| 19 | +// ->setPlatform('all') |
| 20 | +// ->addAllAudience() |
| 21 | +// ->setNotificationAlert('Hi, JPush'); |
| 22 | +// try { |
| 23 | +// $response = $push_payload->send(); |
| 24 | +// print_r($response); |
| 25 | +// } catch (\JPush\Exceptions\APIConnectionException $e) { |
| 26 | +// // try something here |
| 27 | +// print $e; |
| 28 | +// } catch (\JPush\Exceptions\APIRequestException $e) { |
| 29 | +// // try something here |
| 30 | +// print $e; |
| 31 | +// } |
32 | 32 |
|
33 | 33 | // 完整的推送示例
|
34 | 34 | // 这只是使用样例,不应该直接用于实际生产环境中 !!
|
|
44 | 44 | // ->addRegistrationId($registration_id)
|
45 | 45 | ->addAllAudience()
|
46 | 46 |
|
47 |
| - ->setNotificationAlert('Hi, JPush') |
| 47 | + ->setNotificationAlert('Test custom') |
48 | 48 | ->iosNotification('Hello IOS', array(
|
49 | 49 | 'sound' => 'sound.caf',
|
50 | 50 | // 'badge' => '+1',
|
|
90 | 90 | // 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
|
91 | 91 | // 这里设置为 1 仅作为示例
|
92 | 92 |
|
93 |
| - // 'time_to_live' => 1, |
| 93 | + 'time_to_live' => 1, |
94 | 94 |
|
95 | 95 | // apns_production: 表示APNs是否生产环境,
|
96 | 96 | // True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送开发环境
|
97 | 97 |
|
98 |
| - 'apns_production' => false, |
| 98 | + // 'apns_production' => false, |
99 | 99 |
|
100 | 100 | // big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
|
101 | 101 | // 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
|
|
112 | 112 | ),
|
113 | 113 | 'active_filter' => false
|
114 | 114 | ))
|
| 115 | + // custom可自定义最外层参数,如skd未支持部分文档功能,用户可自行写入 |
| 116 | + // 这里仅作为例子展示 |
| 117 | + // ->custom(array( |
| 118 | + // 'sms_message' => array( |
| 119 | + // 'active_filter' => false, |
| 120 | + // 'delay_time' => 60, |
| 121 | + // 'signid' => 154, |
| 122 | + // 'temp_id' => 1, |
| 123 | + // 'temp_para' => array( |
| 124 | + // 'code' => 357 |
| 125 | + // )), |
| 126 | + // 'options' => array( |
| 127 | + // 'apns_production' => false, |
| 128 | + // 'time_to_live' => 62000, |
| 129 | + // ) |
| 130 | + // )) |
115 | 131 | ->send();
|
116 | 132 | print_r($response);
|
117 | 133 |
|
|
0 commit comments