How to use the jpush.JPush function in jpush

To help you get started, we’ve selected a few jpush examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jpush / jpush-api-python-client / tests / devices / test_devices.py View on Github external
import unittest
from tests.conf import app_key, master_secret
from jpush import device
from jpush import common
import jpush as jpush


_jpush = jpush.JPush(app_key, master_secret)
device = _jpush.create_device()
_jpush.set_logging("DEBUG")


class TestEntity(unittest.TestCase):
    def test_create_device(self):
        reg_id = '1507bfd3f7c466c355c'
        entity = jpush.device_tag(jpush.add("ddd", "tageee"))
        result = device.set_devicemobile(reg_id, entity)
        self.assertEqual(result.status_code, 200)

    def test_aliasuser(self):
        alias = "alias1"
        platform = "android,ios"
        result = device.get_aliasuser(alias, platform)
        self.assertEqual(result.status_code, 200)
github jpush / jpush-api-python-client / examples / push_examples / example_notification.py View on Github external
import jpush as jpush
from conf import app_key, master_secret
# from pprint import pprint

_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
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()
github jpush / jpush-api-python-client / examples / report_examples / example_messages.py View on Github external
import jpush as jpush
from examples.conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
report.get_messages("3289406737")
github jpush / jpush-api-python-client / examples / device_examples / example_rmalias.py View on Github external
import jpush as jpush
from examples.conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
alias = "alias1"
platform = "android,ios"
device.delete_alias(alias, platform)
github jpush / jpush-api-python-client / examples / push_examples / example_audience.py View on Github external
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.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()
github jpush / jpush-api-python-client / examples / schedule_examples / example_get_schedule.py View on Github external
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
schedule.get_schedule_by_id("e9c553d0-0850-11e6-b6d4-0021f652c102")
github jpush / jpush-api-python-client / examples / push_examples / example_options.py View on Github external
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_
push.notification = jpush.notification(alert="Hello, world!")
push.platform = jpush.all_
push.options = {"time_to_live":86400, "sendno":12345,"apns_production":True}
push.send()
github jpush / jpush-api-python-client / examples / push_examples / example_alias.py View on Github external
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()
github jpush / jpush-api-python-client / examples / device_examples / example_taglist.py View on Github external
import jpush as jpush
from examples.conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
device.get_taglist()
github malaonline / Server / server / app / tasks.py View on Github external
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_