Skip to content

Commit 921b491

Browse files
author
Helperhaps
committed
huawei push compatible
1 parent 5d2a31a commit 921b491

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

examples/huawei_push_example.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
// 这只是使用样例,不应该直接用于实际生产环境中 !!
3+
4+
require 'config.php';
5+
6+
try {
7+
$payload = $client->push()
8+
->setPlatform(array('ios', 'android'))
9+
// ->addAlias('alias')
10+
->addTag(array('tag1', 'tag2'))
11+
// ->addRegistrationId($registration_id)
12+
->setNotificationAlert('Hi, JPush')
13+
->androidNotification('Hello HUAWEI', array(
14+
'title' => 'huawei demo',
15+
16+
// ---------------------------------------------------
17+
// `uri_activity` 字段用于指定想要打开的 activity.
18+
// 值为 activity 节点的 “android:name” 属性值。
19+
'uri_activity' => 'cn.jpush.android.ui.OpenClickActivity',
20+
// ---------------------------------------------------
21+
22+
'extras' => array(
23+
'key' => 'value',
24+
'jiguang'
25+
),
26+
));
27+
// ->send();
28+
print_r($payload->build());
29+
30+
} catch (\JPush\Exceptions\APIConnectionException $e) {
31+
// try something here
32+
print $e;
33+
} catch (\JPush\Exceptions\APIRequestException $e) {
34+
// try something here
35+
print $e;
36+
}

src/JPush/PushPayload.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,6 @@ public function iosNotification($alert = '', array $notification = array()) {
367367
}
368368

369369
public function androidNotification($alert = '', array $notification = array()) {
370-
# $required_keys = array('title', 'builder_id', 'priority', 'category', 'style',
371-
# 'alert_type', 'big_text', 'inbox', 'big_pic_path', 'extras');
372370
$android = array();
373371
$android['alert'] = is_string($alert) ? $alert : '';
374372
if (!empty($notification)) {
@@ -402,6 +400,7 @@ public function androidNotification($alert = '', array $notification = array())
402400
if (isset($notification['alert_type']) && is_int($notification['alert_type'])) {
403401
$android['alert_type'] = $notification['alert_type'];
404402
}
403+
$android = array_merge($notification, $android);
405404
}
406405
$this->androidNotification = $android;
407406
return $this;

src/JPush/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22
namespace JPush;
33

4-
const VERSION = '3.5.22';
4+
const VERSION = '3.5.23';

0 commit comments

Comments
 (0)