Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jpush-api-python-client
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
jpush-api-python-client
Commits
fc605d59
Commit
fc605d59
authored
Sep 03, 2014
by
hupantingxue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. Fix issue: silent push cannot disable sound;
2. Fix example options issue; 3. Add silent push test case;
parent
669eece8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
5 deletions
+22
-5
example_options.py
examples/push/example_options.py
+1
-1
example_silent.py
examples/push/example_silent.py
+11
-0
core.py
jpush/push/core.py
+1
-2
payload.py
jpush/push/payload.py
+3
-2
test_message.py
tests/push/test_message.py
+6
-0
No files found.
examples/push/example_options.py
View file @
fc605d59
...
...
@@ -6,5 +6,5 @@ push = _jpush.create_push()
push
.
audience
=
jpush
.
all_
push
.
notification
=
jpush
.
notification
(
alert
=
"Hello, world!"
)
push
.
platform
=
jpush
.
all_
push
.
options
=
{
"time_to_live"
:
86400
,
"send
no"
:
12345
,
"apns_production"
:
True
}
push
.
options
=
{
"time_to_live"
:
86400
,
"sendno"
:
12345
,
"apns_production"
:
True
}
push
.
send
()
examples/push/example_silent.py
0 → 100644
View file @
fc605d59
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
push
=
_jpush
.
create_push
()
push
.
audience
=
jpush
.
all_
ios_msg
=
jpush
.
ios
(
alert
=
"Hello, IOS JPush!"
,
badge
=
"+1"
,
extras
=
{
'k1'
:
'v1'
},
sound_disable
=
True
)
android_msg
=
jpush
.
android
(
alert
=
"Hello, android msg"
)
push
.
notification
=
jpush
.
notification
(
alert
=
"Hello, JPush!"
,
android
=
android_msg
,
ios
=
ios_msg
)
push
.
platform
=
jpush
.
all_
push
.
send
()
jpush/push/core.py
View file @
fc605d59
...
...
@@ -45,8 +45,7 @@ class Push(object):
response
=
self
.
_jpush
.
_request
(
'POST'
,
body
,
common
.
PUSH_URL
,
'application/json'
,
version
=
3
)
data
=
response
.
json
()
print
(
response
.
content
)
return
PushResponse
(
response
)
...
...
jpush/push/payload.py
View file @
fc605d59
...
...
@@ -27,7 +27,7 @@ def notification(alert=None, ios=None, android=None, winphone=None):
def
ios
(
alert
=
None
,
badge
=
None
,
sound
=
None
,
content_available
=
False
,
extras
=
None
):
extras
=
None
,
sound_disable
=
False
):
"""iOS/APNS specific platform override payload.
:keyword alert: iOS format alert, as either a string or dictionary.
...
...
@@ -37,6 +37,7 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
for Newsstand iOS applications.
:keyword extra: A set of key/value pairs to include in the push payload
sent to the device.
:keyword sound_disalbe: Disable sound to implement slient push.
>>> ios(alert='Hello!', sound='cat.caf',
... extra={'articleid': '12345'})
...
...
@@ -54,6 +55,7 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
if
isinstance
(
badge
,
str
)
and
not
VALID_AUTOBADGE
.
match
(
badge
):
raise
ValueError
(
"Invalid iOS autobadge value"
)
payload
[
'badge'
]
=
badge
if
not
sound_disable
:
if
sound
is
not
None
:
payload
[
'sound'
]
=
sound
else
:
...
...
@@ -64,7 +66,6 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
payload
[
'extras'
]
=
extras
return
payload
def
android
(
alert
,
title
=
None
,
builder_id
=
None
,
extras
=
None
):
"""Android specific platform override payload.
...
...
tests/push/test_message.py
View file @
fc605d59
...
...
@@ -13,6 +13,12 @@ class TestMessage(unittest.TestCase):
{
'ios'
:
{
'sound'
:
'a.caf'
,
'extras'
:
{
'k1'
:
'v1'
},
'badge'
:
'+1'
,
'alert'
:
'Hello'
}}
)
def
test_iossilent
(
self
):
self
.
assertEqual
(
jpush
.
notification
(
ios
=
jpush
.
ios
(
alert
=
"Hello"
,
badge
=
"+1"
,
extras
=
{
'k1'
:
'v1'
},
sound_disable
=
True
)),
{
'ios'
:
{
'extras'
:
{
'k1'
:
'v1'
},
'badge'
:
'+1'
,
'alert'
:
'Hello'
}}
)
def
test_android
(
self
):
self
.
assertEqual
(
jpush
.
notification
(
android
=
jpush
.
android
(
alert
=
"Hello"
,
extras
=
{
'k2'
:
'v2'
})),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment