Commit 32689984 authored by fendouai's avatar fendouai

add sms message and update the device mobile

parent 0646dd79
......@@ -2,4 +2,5 @@
build/
dist/
jpush.egg-info/
.idea/
app_key = u'dd1066407b044738b6479275'
master_secret = u'2b38ce69b1de2a7fa95706ea'
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'8aae478411e89f7682ed5af6'
......@@ -3,7 +3,7 @@ from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
device = _jpush.create_device()
reg_id = '090c1f59f89'
reg_id = '1507bfd3f7c466c355c'
entity = jpush.device_tag(jpush.add("ddd", "tageee"))
#entity = jpush.device_tag("")
device.set_deviceinfo(reg_id, entity)
device.set_devicemobile(reg_id, entity)
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
device = _jpush.create_device()
reg_id = '1507bfd3f7c466c355c'
entity = jpush.device_mobile("18588232140")
device.set_devicemobile(reg_id, entity)
app_key = u'dd1066407b044738b6479275'
master_secret = u'2b38ce69b1de2a7fa95706ea'
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'8aae478411e89f7682ed5af6'
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_
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()
......@@ -20,6 +20,7 @@ from .push import (
audience,
options,
message,
smsmessage,
)
from .device import (
......@@ -29,6 +30,7 @@ from .device import (
device_tag,
device_alias,
device_regid,
device_mobile,
)
__all__ = [
......@@ -46,6 +48,7 @@ __all__ = [
android,
winphone,
message,
smsmessage,
platform,
audience,
options,
......
......@@ -6,6 +6,7 @@ from .entity import (
device_tag,
device_alias,
device_regid,
device_mobile,
)
__all__ = [
......@@ -15,4 +16,5 @@ __all__ = [
device_tag,
device_alias,
device_regid,
device_mobile,
]
......@@ -45,6 +45,15 @@ class Device(object):
print (url), (body), (info)
return info
def set_devicemobile(self, registration_id, entity):
"""Update deviceinfo with registration id.
"""
url = common.DEVICE_URL + registration_id + "/"
body = json.dumps(entity)
info = self.send("POST", url, body)
print (url), (body), (info)
return info
def delete_tag(self, tag, platform=None):
"""Delete registration id tag.
"""
......
......@@ -53,6 +53,11 @@ def device_tag(*types):
tag["tags"][key] = t[key]
return tag
def device_mobile(device_mobile):
mobile={}
mobile["mobile"]=device_mobile
return mobile
def device_alias(*types):
"""Get an alias object
......
......@@ -16,6 +16,7 @@ from .payload import (
message,
audience,
options,
smsmessage,
)
# Common selector for audience & platform
......@@ -38,4 +39,5 @@ __all__ = [
platform,
audience,
options,
smsmessage,
]
......@@ -15,12 +15,14 @@ class Push(object):
self.platform = None
self.options = None
self.message = None
self.smsmessage=None
@property
def payload(self):
data = {
"audience": self.audience,
"platform": self.platform,
"sms_message":self.smsmessage,
}
if (self.notification is None) and (self.message is None):
raise ValueError("Notification and message cannot be both empty")
......
......@@ -128,6 +128,14 @@ def message(msg_content, title=None, content_type=None, extras=None):
payload['extras'] = extras
return payload
def smsmessage(content,delay_time):
payload = {}
payload["content"]=content
payload["delay_time"]=delay_time
return payload
def platform(*types):
"""Create a platform specifier.
......
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