-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import sys | ||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
|
||
import jpush | ||
|
||
from .conf import app_key, master_secret | ||
|
||
from . import device_example | ||
from . import push_example | ||
from . import report_example | ||
from . import schedule_example | ||
|
||
__all__ = [ | ||
device_example, | ||
push_example, | ||
report_example, | ||
schedule_example | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# please put your app_key and master_secret here | ||
app_key = u'6be9204c30b9473e87bad4dc' | ||
master_secret = u'9349ad7c90292a603c512e92' | ||
master_secret = u'cae22120eed6835e486399a7' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from . import jpush, app_key, master_secret | ||
|
||
_jpush = jpush.JPush(app_key, master_secret) | ||
_jpush.set_logging("DEBUG") | ||
device = _jpush.create_device() | ||
|
||
def alias_user(): | ||
alias = "alias1" | ||
platform = "android,ios" | ||
device.get_aliasuser(alias, platform) | ||
|
||
def ctrl_tag(): | ||
reg_id = '090c1f59f89' | ||
entity = jpush.device_tag("") | ||
device.set_deviceinfo(reg_id, entity) | ||
|
||
def get_device(): | ||
reg_id = '090c1f59f89' | ||
device.get_deviceinfo(reg_id) | ||
|
||
def delete_alias(): | ||
alias = "alias1" | ||
platform = "android,ios" | ||
device.delete_alias(alias, platform) | ||
|
||
def delete_tag(): | ||
tag = "ddd" | ||
platform = "android,ios" | ||
device.delete_tag(tag, platform) | ||
|
||
def check_tag(): | ||
tag = "ddd" | ||
registration_id = '090c1f59f89' | ||
device.check_taguserexist(tag, registration_id) | ||
|
||
def tag_list(): | ||
device.get_taglist() | ||
|
||
def tag_update_user(): | ||
tag = "ddd" | ||
entity = jpush.device_regid(jpush.add("090c1f59f89")) | ||
device.update_tagusers(tag, entity) | ||
|
||
def update_device(): | ||
reg_id = '1507bfd3f7c466c355c' | ||
entity = jpush.device_tag(jpush.add("ddd", "tageee")) | ||
result=device.set_devicemobile(reg_id, entity) | ||
print (result.status_code) | ||
print (result.payload) | ||
|
||
def update_device_mobile(): | ||
reg_id = '1507bfd3f7c466c355c' | ||
entity = jpush.device_mobile("18588232140") | ||
device.set_devicemobile(reg_id, entity) |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
from . import jpush, app_key, master_secret | ||
|
||
_jpush = jpush.JPush(app_key, master_secret) | ||
_jpush.set_logging("DEBUG") | ||
|
||
def alias(): | ||
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() | ||
|
||
def all(): | ||
push = _jpush.create_push() | ||
push.audience = jpush.all_ | ||
push.notification = jpush.notification(alert="!hello python jpush api") | ||
push.platform = jpush.all_ | ||
try: | ||
response=push.send() | ||
except common.Unauthorized: | ||
raise common.Unauthorized("Unauthorized") | ||
except common.APIConnectionException: | ||
raise common.APIConnectionException("conn") | ||
except common.JPushFailure: | ||
print ("JPushFailure") | ||
except: | ||
print ("Exception") | ||
|
||
def audience(): | ||
push = _jpush.create_push() | ||
|
||
push.audience = jpush.audience( | ||
jpush.tag("tag1", "tag2"), | ||
jpush.alias("alias1", "alias2") | ||
) | ||
|
||
|
||
push.notification = jpush.notification(alert="Hello world with audience!") | ||
push.platform = jpush.all_ | ||
print (push.payload) | ||
push.send() | ||
|
||
|
||
def notification(): | ||
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', extras={'k1':'v1'}) | ||
|
||
push.notification = jpush.notification(alert="Hello, JPush!", android=android, ios=ios) | ||
|
||
# pprint (push.payload) | ||
result = push.send() | ||
|
||
def options(): | ||
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, "sendno":12345,"apns_production":True} | ||
push.send() | ||
|
||
def platfrom_msg(): | ||
push = _jpush.create_push() | ||
push.audience = jpush.all_ | ||
ios_msg = jpush.ios(alert="Hello, IOS JPush!", badge="+1", sound="a.caf", extras={'k1':'v1'}) | ||
android_msg = jpush.android(alert="Hello, android msg") | ||
push.notification = jpush.notification(alert="Hello, JPush!", android=android_msg, ios=ios_msg) | ||
push.message=jpush.message("content",extras={'k2':'v2','k3':'v3'}) | ||
push.platform = jpush.all_ | ||
push.send() | ||
|
||
|
||
def silent(): | ||
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() | ||
|
||
|
||
def sms(): | ||
push = _jpush.create_push() | ||
push.audience = jpush.all_ | ||
push.notification = jpush.notification(alert="a sms message from python jpush api") | ||
push.platform = jpush.all_ | ||
push.smsmessage=jpush.smsmessage("a sms message from python jpush api",0) | ||
print (push.payload) | ||
push.send() | ||
|
||
def validate(): | ||
push = _jpush.create_push() | ||
push.audience = jpush.all_ | ||
push.notification = jpush.notification(alert="Hello, world!") | ||
push.platform = jpush.all_ | ||
push.send_validate() |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.