Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def send_push(msg, user_ids=None, extras=None, title=None):
'''
user_ids is a list of user_id [1, 2, ...]
if user_ids is None then send to all
'''
app_key = settings.JPUSH_APP_KEY
master_secret = settings.JPUSH_MASTER_SECRET
_jpush = jpush.JPush(app_key, master_secret)
push = _jpush.create_push()
ios_msg = jpush.ios(alert=msg, extras=extras)
android_msg = jpush.android(alert=msg, extras=extras, title=title)
push.notification = jpush.notification(
alert=msg, android=android_msg, ios=ios_msg)
push.platform = jpush.all_
# for ios dev or prd env
options = dict()
options['apns_production'] = settings.APNS_PRODUCTION
jpush.options(options)
if user_ids is None:
push.audience = jpush.all_
return str(push.send())
elif len(user_ids) > 1000:
ans = []
for i in range(len(user_ids) // 1000 + 1):
import jpush as jpush
from examples.conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
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()
import jpush as jpush
from examples.conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
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.platform = jpush.all_
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 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()
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()
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()