From 5688ac2c358d7f506096716502c3bc25673ffc15 Mon Sep 17 00:00:00 2001 From: Helperhaps Date: Mon, 16 Oct 2017 06:56:06 +0000 Subject: [PATCH 1/4] huawei push compatible --- examples/huawei_example.py | 23 +++++++++++++++++++++++ jpush/push/payload.py | 6 +++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 examples/huawei_example.py diff --git a/examples/huawei_example.py b/examples/huawei_example.py new file mode 100644 index 0000000..1d382d3 --- /dev/null +++ b/examples/huawei_example.py @@ -0,0 +1,23 @@ +from . import jpush, app_key, master_secret + +_jpush = jpush.JPush(app_key, master_secret) +_jpush.set_logging("DEBUG") + + +def huawei(): + push = _jpush.create_push() + + push.audience = jpush.all_ + push.platform = jpush.all_ + + ios = jpush.ios(alert="Hello, IOS JPush!", sound="a.caf", extras={'k1':'v1'}) + android = jpush.android(alert="Hello, Android msg", + priority=1, style=1, alert_type=1,big_text='jjjjjjjjjj', + uri_activity='cn.jpush.android.ui.OpenClickActivity', + extras={'k1':'v1'}) + + push.notification = jpush.notification(alert="Hello, JPush!", android=android, ios=ios) + + # pprint (push.payload) + result = push.send() + diff --git a/jpush/push/payload.py b/jpush/push/payload.py index 4063093..e0401b8 100644 --- a/jpush/push/payload.py +++ b/jpush/push/payload.py @@ -81,7 +81,9 @@ def ios(alert=None, badge='+1', sound=None, content_available=False, return payload def android(alert, title=None, builder_id=None, extras=None, - priority=None, category=None, style=None, alert_type=None,big_text=None, inbox=None, big_pic_path=None): + priority=None, category=None, style=None, + alert_type=None,big_text=None, inbox=None, big_pic_path=None, + uri_activity=None): """Android specific platform override payload. :keyword alert: String alert text.If you set alert to a empty string,then the payload @@ -114,6 +116,8 @@ def android(alert, title=None, builder_id=None, extras=None, payload['inbox'] = inbox if big_pic_path is not None: payload['big_pic_path'] = big_pic_path + if uri_activity is not None: + payload['uri_activity'] = uri_activity if extras is not None: payload['extras'] = extras return payload From 30b4e8a16b29923153514e0a25c34bf21f637e67 Mon Sep 17 00:00:00 2001 From: Helperhaps Date: Mon, 16 Oct 2017 07:15:14 +0000 Subject: [PATCH 2/4] update README --- README.md | 15 +++++---------- README.rst | 12 +----------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 4d13414..10c4301 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,22 @@ # JPush API Python Client ## 概述 + 这是 JPush REST API 的 Python 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。 对应的 REST API 文档: ## 兼容版本 + + Python 2.7 + Python 3 ## 环境配置 -pip 方式: -``` -sudo pip install jpush -``` -easy_install 方式: -``` -sudo easy_install jpush -``` -使用源码方式: +使用源码安装: + ``` -sudo python setup.py install +$ python setup.py install ``` diff --git a/README.rst b/README.rst index cbc9414..4b65632 100644 --- a/README.rst +++ b/README.rst @@ -11,18 +11,8 @@ You can download the latest release file here: https://github.com/jpush/jpush-ap ------------ Installation ------------ -To install jpush-api-python-client, simply: - $ sudo pip install jpush - -or alternatively install via easy_install: - - $ sudo easy_install jpush - - -or from source: - - $ sudo python setup.py install +$ python setup.py install ------- Testing From b16e8611ed07bdc7887e7c7117fa44ebadf19504 Mon Sep 17 00:00:00 2001 From: Helperhaps Date: Tue, 17 Oct 2017 10:33:34 +0000 Subject: [PATCH 3/4] update examples --- examples/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/__init__.py b/examples/__init__.py index f1318b5..c02f722 100644 --- a/examples/__init__.py +++ b/examples/__init__.py @@ -11,11 +11,13 @@ from . import report_example from . import schedule_example from . import group_push_example +from . import huawei_example __all__ = [ device_example, push_example, report_example, schedule_example, - group_push_example + group_push_example, + huawei_example ] From bfc018ba61a61e6130b36364a3a9a8dde898b0e7 Mon Sep 17 00:00:00 2001 From: Helperhaps Date: Wed, 18 Oct 2017 02:54:58 +0000 Subject: [PATCH 4/4] python2 compatible --- jpush/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpush/core.py b/jpush/core.py index 7b87c25..fee2fb6 100644 --- a/jpush/core.py +++ b/jpush/core.py @@ -93,7 +93,7 @@ def create_schedule(self): class GroupPush(JPush): def __init__(self, key, secret): - super().__init__('group-' + key, secret) + JPush.__init__(self, 'group-' + key, secret) def create_push(self): """Create a Group Push notification."""