Ejemplo n.º 1
0
def buildMessage(data):
	mess = xinge.Message()
        mess.type = data[KEY.TYPE]
	mess.title = data[KEY.TITLE]
        mess.content = data[KEY.CONTENT]
        mess.expireTime = 86400
        '''含义:样式编号0 ,响铃,震动,不可从通知栏清除'''
        mess.style = data[KEY.STYLE]
        '''we use the default action, that's to open the app'''
        mes.action = data[KEY.ACTION]
        t1 = xinge.TimeInterval(0, 0, 13, 59)
        t2 = xinge.TimeInterval(14, 0, 23, 59)
        mess.acceptTime = (t1, t2)
        return mess
Ejemplo n.º 2
0
def buildMessage(type=2, title='', content='', style=None, action=None, custom=None):
        mess = xinge.Message()
        mess.type = type
        mess.title = title
        mess.content = content
        mess.expireTime = 86400
        '''含义:样式编号0 ,响铃,震动,不可从通知栏清除'''
        mess.style = style
        '''we use the default action, that's to open the app'''
        if action is not None:
            action = xinge.ClickAction(activity=action)
        mess.action = action
        mess.custom = custom
        t1 = xinge.TimeInterval(0, 0, 13, 59)
        t2 = xinge.TimeInterval(14, 0, 23, 59)
        mess.acceptTime = (t1, t2)
        return mess
Ejemplo n.º 3
0
def BuildMsg():
    msg = xinge.Message()
    msg.type = xinge.Message.TYPE_MESSAGE
    msg.title = 'some title'
    msg.content = 'some content'
    # 消息为离线设备保存的时间,单位为秒。默认为0,表示只推在线设备
    msg.expireTime = 86400
    # 定时推送,若不需定时可以不设置
    #msg.sendTime = '2012-12-12 18:48:00'
    # 自定义键值对,key和value都必须是字符串
    msg.custom = {'aaa': '111', 'bbb': '222'}
    # 使用多包名推送模式,详细说明参见文档和wiki,如果您不清楚该字段含义,则无需设置
    #msg.multiPkg = 1

    # 允许推送时段设置,非必须
    #ti1 = xinge.TimeInterval(9, 30, 11, 30)
    #ti2 = xinge.TimeInterval(14, 0, 17, 0)
    #msg.acceptTime = (ti1, ti2)

    return msg
Ejemplo n.º 4
0
def BuildNotification():
    msg = xinge.Message()
    msg.type = xinge.Message.TYPE_NOTIFICATION
    msg.title = 'some title'
    msg.content = 'some content'
    # 消息为离线设备保存的时间,单位为秒。默认为0,表示只推在线设备
    msg.expireTime = 86400
    # 定时推送,非必须
    #msg.sendTime = '2012-12-12 18:48:00'
    # 自定义键值对,key和value都必须是字符串,非必须
    msg.custom = {'aaa': '111', 'bbb': '222'}
    # 使用多包名推送模式,详细说明参见文档和wiki,如果您不清楚该字段含义,则无需设置
    #msg.multiPkg = 1

    # 允许推送时段设置,非必须
    #ti1 = xinge.TimeInterval(9, 30, 11, 30)
    #ti2 = xinge.TimeInterval(14, 0, 17, 0)
    #msg.acceptTime = (ti1, ti2)

    # 通知展示样式,仅对通知有效
    # 样式编号为2,响铃,震动,不可从通知栏清除,不影响先前通知
    style = xinge.Style(2, 1, 1, 0, 0)
    msg.style = style

    # 点击动作设置,仅对通知有效
    # 以下例子为点击打开url
    action = xinge.ClickAction()
    action.actionType = xinge.ClickAction.TYPE_URL
    action.url = 'http://xg.qq.com'
    # 打开url不需要用户确认
    action.confirmOnUrl = 0
    msg.action = action

    # 以下例子为点击打开intent。例子中的intent将打开拨号界面并键入10086
    # 使用intent.toUri(Intent.URI_INTENT_SCHEME)方法来得到序列化后的intent字符串,自定义intent参数也包含在其中
    #action = xinge.ClickAction()
    #action.actionType = xinge.ClickAction.TYPE_INTENT
    #action.intent = 'intent:10086#Intent;scheme=tel;action=android.intent.action.DIAL;S.key=value;end'
    #msg.action = action

    return msg
Ejemplo n.º 5
0
def customedPush(msg):
    xios = xinge.XingeApp(2200050216, '2f7f56e61191393d6b25079ee9d839b0')
    ios = xinge.MessageIOS()
    ios.alert = msg
    ios.sound = "default"
    ios.badge = 1
    ios.expireTime = 86400
    ret = xios.PushAllDevices(0, ios, 1)

    xandroid = xinge.XingeApp(2100081128, 'db2f948d8f2b962fc4e1cb4a26f7d87d')
    android = xinge.Message()
    android.type = xinge.Message.TYPE_NOTIFICATION
    android.title = '快乐居家'
    android.content = msg
    android.expireTime = 86400
    res = xandroid.PushAllDevices(0, android)

    if ret[0] == 0 and res[0] == 0:
        return True
    else:
        return False
Ejemplo n.º 6
0
    def run(self):
        while True:
            cursor = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
            cursor.execute(
                "SELECT * FROM tb_notice_push where state=0 or state=-100 order by pushtime limit 100"
            )
            rows = cursor.fetchall()
            if len(rows) > 0:
                updatesql = ''
                for row in rows:
                    try:
                        userId = row['userid']
                        content = row['content']
                        noticetype = 1 if row['noticetype'] == 1 else 2
                        if row['clienttype'] == 1:
                            xg = android_xg
                            msg = xinge.Message()
                            msg.type = xinge.Message.TYPE_NOTIFICATION
                            msg.title = '家庭作业' if noticetype == 1 else '学校通知'
                            msg.content = content
                            msg.expireTime = 3600
                            msg.custom = {
                                'noticeid': row['noticeid'],
                                'noticetype': 0
                            }
                            msg.type = xinge.Message.TYPE_NOTIFICATION
                            style = xinge.Style(1, 1, 1, 1, 5)
                            msg.action = xinge.ClickAction(
                                1, '', 0,
                                'cn.youteach.xxt2.activity.notify.NoticeInfoActivity',
                                '')
                            msg.style = style
                            ret = xg.PushSingleAccount(0, userId, msg,
                                                       row['clienttype'] - 1)
                        else:
                            xg = ios_xg
                            noticeId = row['noticeid']
                            msg = xinge.MessageIOS()
                            msg.badge = 1
                            msg.sound = 'default'
                            msg.alert = content
                            msg.expireTime = 3600
                            msg.custom = {'messageid': noticeId}
                            ret = xg.PushSingleAccount(2, userId, msg,
                                                       row['clienttype'] - 1)

                            #xg = xinge.XingeApp(2200062766, 'c9206fa64a4cb03ed712c1ea4f23ffb1')
                            #msg = xinge.MessageIOS()
                            #msg.alert = content
                            #msg.expireTime = 3600
                            # 自定义键值对,value可以是json允许的类型
                            #msg.custom = {'noticeid':row['noticeid'],'noticetype':noticetype}

                        print ret
                        state, m = ret
                        state = 1 if state == 0 else state
                        sql = "update tb_notice_push set state=" + str(
                            state) + " where pushid=" + str(
                                row['pushid']) + ";"
                        updatesql = updatesql + sql
                    except Exception as e:
                        logger(e, 'push')

                if updatesql:
                    try:
                        cursor = conn.cursor()
                        cursor.execute(updatesql)
                    except Exception as e:
                        logger(e, 'push')
            time.sleep(1)
Ejemplo n.º 7
0
#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''

Copyright © 1998 - 2013 Tencent. All Rights Reserved. 腾讯公司 版权所有

'''

import sys
import xinge

mess = xinge.Message()  #mess = MessageIOS()
mess.type = xinge.Message.TYPE_NOTIFICATION
mess.title = sys.argv[2]
mess.content = sys.argv[3]
mess.multiPkg = 1

#含义:样式编号0,响铃,震动,不可从通知栏清除
#mess.style = Style(0,1,1,0)
#action = ClickAction()
#action.actionType = ClickAction::TYPE_URL
#action.url = "http://xg.qq.com"
#mess.action = $action
#mess.custom = {'key1':'value1', 'key2':'value2'}
#t1 = TimeInterval(12, 0, 13, 59)
#t2 = TimeInterval(19, 0, 20, 59)
#mess.acceptTime = (t1, t2)

push = xinge.XingeApp(2100145241, '37c1e7cb4edf243e2a5279315310dd04')

#完善Message 消息