Python:极光推送(Jpush)

极光推送的整体流程:

APP -->注册过滤字段(device_id、robot.uuid)--> 后台指定过滤字段 -->极光服务器发送给指定APP

与Python交互

# 极光推送
content = {"task_res": -1, 'task_type': main_task, 'clean_mode': -1, 'error_code': error_code,"robot_name": robot_obj.robot_name}
data = MessageResponse(title='robot error', code=settings.JPUSH_MESSAGE_TYPE_DICT['robot_error'],content=content)
message = data.jsonify()
# 中文推送
cn_title = get_error_title(robot_obj.robot_name, error_code, "cn")
# "alias":推送的方法,message:推送的内容,list_tags:指定过滤字段,title:推送给主页面的主题
jpush_message('alias', message=message, list_tags=[robot_obj.uuid, settings.tag["cn"]],title=cn_title, )
# 英文推送
en_title = get_error_title(robot_obj.robot_name, error_code, "en")
jpush_message('alias', message=message, list_tags=[robot_obj.uuid, settings.tag["en"]],title=en_title, )
发布了61 篇原创文章 · 获赞 11 · 访问量 6465

猜你喜欢

转载自blog.csdn.net/weixin_41449756/article/details/103453394