def sendAndroidUnicast(): # 以英文逗号判断使用列推还是单推 if ',' in deviceTokens: unicast=AndroidListcast(appKey, appMasterSecret) else: unicast = AndroidUnicast(appKey, appMasterSecret) unicast.setDeviceToken(deviceTokens) unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION) unicast.setTicker(inputdict['title']+':'+inputdict['text']) unicast.setTitle(inputdict['title']) unicast.setText(inputdict['text']) # 无论如何都打开这个activity,看具体你的客户端业务如何使用 # unicast.goActivityAfterOpen(activityAfter) unicast.goCustomAfterOpen(custom) # 正式环境 # unicast.setProductionMode() # 测试环境 unicast.setTestMode() unicast.serExtra({inputdict["extraKey"]:inputdict["extraValue"]}) # 虽然叫MiActivity 其实是所有厂商的推送通道,不只是小米 unicast.setMiPush('true') unicast.setMiActivity(activityAfter) pushClient = PushClient() pushClient.send(unicast)
def sendIOSBroadcast(): broadcast = IOSBroadcast(appKey, appMasterSecret) broadcast.setAlert("这个是一个iOS广播测试") broadcast.setBadge(1234) broadcast.setTestMode() pushClient = PushClient() pushClient.send(broadcast)
def sendIOSGroupcast(): #condition: #"where": #{ # "and": # [ # {"tag" :"iostest"} # ] # } / groupcast = IOSGroupcast(appKey, appMasterSecret) filterJson = json.loads('{}') whereJson = json.loads('{}') testTag = json.loads('{}') testTag['tag'] = "iostest" tagArray = [testTag] whereJson['and'] = tagArray filterJson['where'] = whereJson groupcast.setFilter(filterJson) groupcast.setAlert("IOS 组播测试") groupcast.setBadge(1); groupcast.setSound("default") groupcast.setTestMode() pushClient = PushClient() ret = pushClient.send(groupcast) printResult(ret)
def sendIOSCustomizedcast(): customizedcast = IOSCustomizedcast(appKey, appMasterSecret) customizedcast.setAlias("alias", "alias_type"); customizedcast.setAlert("这个是一个iOS个性化测试") customizedcast.setBadge(1234) customizedcast.setTestMode() pushClient = PushClient() pushClient.send(customizedcast)
def sendIOSListcast(): listcast = IOSListcast(appKey, appMasterSecret) listcast.setDeviceToken("xxx,yyy,zzz") listcast.setAlert("这个是一个iOS列播测试") listcast.setBadge(1234) listcast.setTestMode() pushClient = PushClient() pushClient.send(listcast)
def sendUmengBroadcast(ticker, title, text): broadcast = AndroidBroadcast(umengAppKey, umengAppMasterSecret) broadcast.setTicker(ticker) broadcast.setTitle(title) broadcast.setText(text) broadcast.goAppAfterOpen() broadcast.setDisplayType(AndroidNotification.DisplayType.notification) broadcast.setTestMode() pushClient = PushClient() pushClient.send(broadcast)
def sendIOSFilecast(): #fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb"); fileId = "fileid1" filecast = IOSFilecast(appKey, appMasterSecret) filecast.setFileId(fileId); filecast.setAlert("这个是一个iOS组播测试") filecast.setBadge(1234) filecast.setTestMode() pushClient = PushClient() pushClient.send(filecast)
def sendUmengListcast(deviceTokenList, ticker, title, text): listcast = AndroidListcast(umengAppKey, umengAppMasterSecret) listcast.setDeviceToken(deviceTokenList) listcast.setTicker(ticker) listcast.setTitle(title) listcast.setText(text) listcast.goAppAfterOpen() listcast.setDisplayType(AndroidNotification.DisplayType.notification) listcast.setTestMode() pushClient = PushClient() pushClient.send(listcast)
def sendUmengUnicast(deviceToken, ticker, title, text): unicast = AndroidUnicast(umengAppKey, umengAppMasterSecret) unicast.setDeviceToken(deviceToken) unicast.setTicker(ticker) unicast.setTitle(title) unicast.setText(text) unicast.goAppAfterOpen() unicast.setDisplayType(AndroidNotification.DisplayType.notification) unicast.setTestMode() pushClient = PushClient() pushClient.send(unicast)
def sendIOSUnicast(): unicast = IOSUnicast(appKey, appMasterSecret) unicast.setDeviceToken(deviceTokens) unicast.setAlert("这个是一个iOS单播测试") unicast.setBadge(1234) unicast.setCustomizedField("test", "helloworld"); unicast.setProductionMode() pushClient = PushClient() ret = pushClient.send(unicast) unicast.statuCode = ret.status_code; printResult(ret)
def sendAndroidUnicast(): unicast = AndroidUnicast(appKey, appMasterSecret) unicast.setDeviceToken(deviceToken) unicast.setTicker("Android unicast ticker") unicast.setTitle("中文的title") unicast.setText("Android unicast text") unicast.goAppAfterOpen() unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION) unicast.setTestMode() pushClient = PushClient() pushClient.send(unicast)
def sendAndroidBroadcast(): broadcast = AndroidBroadcast(appKey, appMasterSecret) broadcast.setTicker("Android broadcast ticker") broadcast.setTitle("中文的title") broadcast.setText("Android broadcast text") broadcast.goAppAfterOpen() broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION) broadcast.setTestMode() #Set customized fields broadcast.setExtraField("test", "helloworld") pushClient = PushClient() pushClient.send(broadcast)
def sendContentAvailableIOSUnicast(device_token, messageType="topic", test=False): unicast = IOSUnicast(iOSappKey, iOSappMasterSecret) unicast.setDeviceToken(device_token) unicast.setContentAvailable(1) unicast.setCustomizedField("messageType", messageType) if test: unicast.setTestMode() else: unicast.setProductionMode() pushClient = PushClient() ret = pushClient.send(unicast) unicast.statuCode = ret.status_code printResult(ret)
def sendIOSUnicast(message, badge, device_token, messageType="topic", test=False, data={}): unicast = IOSUnicast(iOSappKey, iOSappMasterSecret) unicast.setDeviceToken(device_token) unicast.setAlert(message) unicast.setBadge(badge) unicast.setCustomizedField("messageType", messageType) for key, value in data.items(): unicast.setCustomizedField(key, value) if test: unicast.setTestMode() else: unicast.setProductionMode() pushClient = PushClient() ret = pushClient.send(unicast) unicast.statuCode = ret.status_code printResult(ret)
def sendAndroidBroadcast(): broadcast = AndroidBroadcast(appKey, appMasterSecret) broadcast.setTicker(inputdict['title']+':'+inputdict['text']); broadcast.setTitle(inputdict['title']); broadcast.setText(inputdict['text']); # broadcast.goAppAfterOpen(activityAfter); broadcast.goCustomAfterOpen(custom); broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); # 正式环境 # broadcast.setProductionMode() broadcast.setTestMode() #Set customized fields broadcast.serExtra({inputdict["extraKey"]: inputdict["extraValue"]}); broadcast.setMiPush('true') broadcast.setMiActivity(activityAfter) pushClient = PushClient() pushClient.send(broadcast)
def sendIOSBroadcast(app, message, badge, messageType="hot_news", test=False, data={}): appKey = iOSappKey appMasterSecret = iOSappMasterSecret if app == "personal": appKey = iOSappKey_personal appMasterSecret = iOSappMasterSecret_personal broadcast = IOSBroadcast(appKey, appMasterSecret) broadcast.setAlert(message) broadcast.setBadge(badge) broadcast.setCustomizedField("messageType", messageType) for key, value in data.items(): broadcast.setCustomizedField(key, value) if test: broadcast.setTestMode() else: broadcast.setProductionMode() pushClient = PushClient() ret = pushClient.send(broadcast) printResult(ret)