Commit 53c93d2d authored by fendouai's avatar fendouai Committed by GitHub

Merge branch 'dev' into fix_python2_unicode

parents 9631af9e 4fb7f5d9
# please put your app_key and master_secret here # please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc' app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92' master_secret = u'a564b268ba23631a8a34e687'
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
alias=["alias1", "alias2"]
alias1={"alias": alias}
print alias1
push.audience = jpush.audience(
jpush.tag("tag1", "tag2"),
alias1
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print (push.payload)
push.send()
\ No newline at end of file
...@@ -3,10 +3,13 @@ from conf import app_key, master_secret ...@@ -3,10 +3,13 @@ from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret) _jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG") _jpush.set_logging("DEBUG")
push = _jpush.create_push() push = _jpush.create_push()
push.audience = jpush.audience( push.audience = jpush.audience(
jpush.tag("tag1", "tag2"), jpush.tag("tag1", "tag2"),
jpush.alias("alias1", "alias2") jpush.alias("alias1", "alias2")
) )
push.notification = jpush.notification(alert="Hello world with audience!") push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_ push.platform = jpush.all_
print (push.payload) print (push.payload)
......
...@@ -56,7 +56,7 @@ def ios(alert=None, badge=None, sound=None, content_available=False, ...@@ -56,7 +56,7 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
""" """
payload = {} payload = {}
if alert is not None: if alert is not None:
if not (isinstance(alert, string_types) or isinstance(alert, dict)): if not isinstance(alert, (str, dict)):
raise ValueError("iOS alert must be a string or dictionary") raise ValueError("iOS alert must be a string or dictionary")
payload['alert'] = alert payload['alert'] = alert
if badge is not None: if badge is not None:
...@@ -79,8 +79,9 @@ def ios(alert=None, badge=None, sound=None, content_available=False, ...@@ -79,8 +79,9 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
def android(alert, title=None, builder_id=None, extras=None): def android(alert, title=None, builder_id=None, extras=None):
"""Android specific platform override payload. """Android specific platform override payload.
All keyword arguments are optional. :keyword alert: String alert text.If you set alert to a empty string,then the payload
will not display on notification bar.
more info:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#notification
:keyword alert: String alert text. :keyword alert: String alert text.
:keyword title: String :keyword title: String
:keyword builder_id: Integer :keyword builder_id: Integer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment