Exemplo n.º 1
0
def NotificationTemplateIOS82Co(title=u"标题",
                                desc=u"说明",
                                content="",
                                app_name=""):
    template = get_transmission_template_co(content, app_name)
    # 设置APNS信息
    apnpayload = APNPayload()
    apnpayload.badge = 1
    # apnpayload.sound = "test1.wav"
    apnpayload.contentAvailable = 1
    apnpayload.category = "ACTIONABLE"
    # # 简单类型如下设置
    # alertMsg = SimpleAlertMsg()
    # alertMsg.alertMsg = desc
    #字典类型如下设置
    alertMsg = DictionaryAlertMsg()
    alertMsg.body = desc
    alertMsg.actionLocKey = 'actionLockey'
    alertMsg.locKey = desc.encode("utf-8")
    alertMsg.locArgs = ['loc-args']
    alertMsg.launchImage = 'launchImage'
    # IOS8.2以上版本支持
    alertMsg.title = title
    #alertMsg.titleLocArgs = ['TitleLocArg']
    #alertMsg.titleLocKey = 'TitleLocKey'
    #可以设置字典类型AlertMsg和简单类型AlertMsg其中之一
    apnpayload.alertMsg = alertMsg
    apnpayload.addCustomMsg("result", content)
    template.setApnInfo(apnpayload)
    return template
Exemplo n.º 2
0
def pushAPN():

    push = IGeTui(HOST, APPKEY, MASTERSECRET)
    message = IGtSingleMessage()

    # APN旧版推送Demo
    #     template = APNTemplate()
    #     template.setPushInfo("", -1,"", "", "", "", "", "")

    # APN简单推送
    template = APNTemplate()
    apn = APNPayload()
    alertMsg = SimpleAlertMsg()
    alertMsg.alertMsg = ""
    apn.alertMsg = alertMsg
    apn.badge = 2
    apn.sound = ""
    apn.addCustomMsg("payload", "payload")
    #     apn.contentAvailable=1
    #     apn.category="ACTIONABLE"
    template.setApnInfo(apn)

    # APN高级推送
    #     template = APNTemplate()
    #     apnpayload = APNPayload()
    #     apnpayload.badge = 4
    #     apnpayload.sound = "sound"
    #     apnpayload.addCustomMsg("payload", "payload")
    # #     apnpayload.contentAvailable = 1
    # #     apnpayload.category = "ACTIONABLE"
    #
    #
    #     alertMsg = DictionaryAlertMsg()
    #     alertMsg.body = 'body'
    #     alertMsg.actionLocKey = 'actionLockey'
    #     alertMsg.locKey = 'lockey'
    #     alertMsg.locArgs=['locArgs']
    #     alertMsg.launchImage = 'launchImage'
    #     # IOS8.2以上版本支持
    # #     alertMsg.title = 'Title'
    # #     alertMsg.titleLocArgs = ['TitleLocArg']
    # #     alertMsg.titleLocKey = 'TitleLocKey'
    #     apnpayload.alertMsg=alertMsg
    #     template.setApnInfo(apnpayload)

    # 单个用户推送接口
    message.data = template
    # print DEVICETOKEN
    ret = push.pushAPNMessageToSingle(APPID, DEVICETOKEN, message)
    print message
    print ret
Exemplo n.º 3
0
def pushAPN():

    push = IGeTui(HOST, APPKEY, MASTERSECRET)
    message = IGtSingleMessage()
    
   # APN旧版推送Demo 
#     template = APNTemplate()
#     template.setPushInfo("", -1,"", "", "", "", "", "")
    
# APN简单推送
    template = APNTemplate()
    apn = APNPayload();
    alertMsg = SimpleAlertMsg()
    alertMsg.alertMsg = ""
    apn.alertMsg = alertMsg
    apn.badge = 2
    apn.sound = ""
    apn.addCustomMsg("payload", "payload")
#     apn.contentAvailable=1
#     apn.category="ACTIONABLE"
    template.setApnInfo(apn)
    
# APN高级推送
#     template = APNTemplate()
#     apnpayload = APNPayload()
#     apnpayload.badge = 4
#     apnpayload.sound = "sound"
#     apnpayload.addCustomMsg("payload", "payload")
# #     apnpayload.contentAvailable = 1
# #     apnpayload.category = "ACTIONABLE"
#         
#         
#     alertMsg = DictionaryAlertMsg()
#     alertMsg.body = 'body'
#     alertMsg.actionLocKey = 'actionLockey'
#     alertMsg.locKey = 'lockey'
#     alertMsg.locArgs=['locArgs']
#     alertMsg.launchImage = 'launchImage'
#     # IOS8.2以上版本支持
# #     alertMsg.title = 'Title'
# #     alertMsg.titleLocArgs = ['TitleLocArg']
# #     alertMsg.titleLocKey = 'TitleLocKey'
#     apnpayload.alertMsg=alertMsg
#     template.setApnInfo(apnpayload)

    # 单个用户推送接口
    message.data = template
    ret = push.pushAPNMessageToSingle(APPID, DEVICETOKEN, message)
    print message
    print ret
Exemplo n.º 4
0
def TransmissionTemplateDemo():
    template = TransmissionTemplate()
    template.transmissionType = 1
    template.appId = APPID
    template.appKey = APPKEY
    template.transmissionContent = '请填入透传内容'
    # iOS 推送需要的PushInfo字段 前三项必填,后四项可以填空字符串
    # template.setPushInfo(actionLocKey, badge, message, sound, payload, locKey, locArgs, launchImage)
#     template.setPushInfo("", 0, "", "com.gexin.ios.silence", "", "", "", "");

# APN简单推送
    alertMsg = SimpleAlertMsg()
    alertMsg.alertMsg = ""
    apn = APNPayload();
    apn.alertMsg = alertMsg
    apn.badge = 2
#     apn.sound = ""
    apn.addCustomMsg("payload", "payload")
#     apn.contentAvailable=1
#     apn.category="ACTIONABLE"
    template.setApnInfo(apn)

    # APN高级推送
#     apnpayload = APNPayload()
#     apnpayload.badge = 4
#     apnpayload.sound = "com.gexin.ios.silence"
#     apnpayload.addCustomMsg("payload", "payload")
# #     apnpayload.contentAvailable = 1
# #     apnpayload.category = "ACTIONABLE"
#     alertMsg = DictionaryAlertMsg()
#     alertMsg.body = 'body'
#     alertMsg.actionLocKey = 'actionLockey'
#     alertMsg.locKey = 'lockey'
#     alertMsg.locArgs=['locArgs']
#     alertMsg.launchImage = 'launchImage'
#     # IOS8.2以上版本支持
# #     alertMsg.title = 'Title'
# #     alertMsg.titleLocArgs = ['TitleLocArg']
# #     alertMsg.titleLocKey = 'TitleLocKey'
#     apnpayload.alertMsg=alertMsg
#     template.setApnInfo(apnpayload)
    
    
    return template
Exemplo n.º 5
0
def TransmissionTemplateDemo():
    template = TransmissionTemplate()
    template.transmissionType = 1
    template.appId = APPID
    template.appKey = APPKEY
    template.transmissionContent = '请填入透传内容'
    # iOS 推送需要的PushInfo字段 前三项必填,后四项可以填空字符串
    # template.setPushInfo(actionLocKey, badge, message, sound, payload, locKey, locArgs, launchImage)
#     template.setPushInfo("", 0, "", "com.gexin.ios.silence", "", "", "", "");

# APN简单推送
    alertMsg = SimpleAlertMsg()
    alertMsg.alertMsg = ""
    apn = APNPayload();
    apn.alertMsg = alertMsg
    apn.badge = 2
#     apn.sound = ""
    apn.addCustomMsg("payload", "payload")
#     apn.contentAvailable=1
#     apn.category="ACTIONABLE"
    template.setApnInfo(apn)

    # APN高级推送
#     apnpayload = APNPayload()
#     apnpayload.badge = 4
#     apnpayload.sound = "com.gexin.ios.silence"
#     apnpayload.addCustomMsg("payload", "payload")
# #     apnpayload.contentAvailable = 1
# #     apnpayload.category = "ACTIONABLE"
#     alertMsg = DictionaryAlertMsg()
#     alertMsg.body = 'body'
#     alertMsg.actionLocKey = 'actionLockey'
#     alertMsg.locKey = 'lockey'
#     alertMsg.locArgs=['locArgs']
#     alertMsg.launchImage = 'launchImage'
#     # IOS8.2以上版本支持
# #     alertMsg.title = 'Title'
# #     alertMsg.titleLocArgs = ['TitleLocArg']
# #     alertMsg.titleLocKey = 'TitleLocKey'
#     apnpayload.alertMsg=alertMsg
#     template.setApnInfo(apnpayload)
    
    
    return template