Ejemplo 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
Ejemplo n.º 2
0
def TransmissionTemplateDemo():
    template = TransmissionTemplate()
    template.transmissionType = 1
    template.appId = APPID
    template.appKey = APPKEY
    template.transmissionContent = '中午你跟'
    notify = Notify()
    # notify.title = "titleee"
    # notify.content = "contentee"
    # notify.payload = 'payloadtest'
    # notify.type = NotifyInfo._payload

    # notify.title = "titleee"
    # notify.content = "contentee"
    # notify.intent = "intent:#Intent;component=com.pp.infonew/com.getui.demo.MainActivity;S.key1=value1;end"
    # notify.type = NotifyInfo._intent

    notify.title = "ThirdPartyUrl"
    notify.content = "contentee"
    notify.url = "http://www.getui.com"
    notify.type = NotifyInfo._url
    template.set3rdNotifyInfo(notify)

    # # 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.autoBadge = "+1"
    apnpayload.sound = ""
    apnpayload.addCustomMsg("payload", "payload")
    apnpayload.contentAvailable = 1
    apnpayload.category = "ACTIONABLE"
    apnpayload.voicePlayType = 2
    apnpayload.voicePlayMessage = ""
    alertMsg = DictionaryAlertMsg()
    alertMsg.body = 'body'
    alertMsg.actionLocKey = 'actionLockey'
    alertMsg.locArgs = ['locArgs']
    alertMsg.launchImage = 'launchImage'
    # IOS8.2以上版本支持
    alertMsg.title = 'Title'
    alertMsg.titleLocArgs = ['TitleLocArg']
    alertMsg.titleLocKey = 'TitleLocKey'
    apnpayload.alertMsg = alertMsg
    # voIPPayload = VoIPPayload()
    # voIPPayload.setVoIPPayload("Payload")
    template.setApnInfo(apnpayload)
    return template