魅族推送平台接入文档 (JAVA-SDK)

Similar documents
集成推送平台 JAVA 版本 SDK JavaPushSdk 发布说明 ( 请使用最新版本 ) 中央仓库获取 MVN Repository 或者 Central Repository 直接下载获取 Java Server SDK 更新日志 [ ]V

魅族开放平台 PUSH 系统 JAVA 版本 SDK JavaPushSdk 发布说明 ( 请使用最新版本 ) 中央仓库获取 MVN Repository 或者 Central Repository 直接下载获取 Java Server SDK 更新日志 [ ]V

推送平台开放接口

推送平台开放接口

上述字符串的 MD5 值即为签名的值 (32 位小写 ) 将签名值放在请求的参数中例如 sign=md5_sign 服务端 SDK 调用 API 的应用的私钥 Secret Key 为 appsecret /** parammap 请求参数 secret 密钥 *

1005 错误, 请参考 API 文档 1006 签名认证失败 不合法 appkey 不合法 不能为空 应用被加入黑名单 应用推送速率过快 透传超过限制 接口签名规范 请求分别是 k1 k2 k3, 它们的值分别是

获取 Access Token access_token 是接口的全局唯一票据, 接入方调用各接口时都需使用 access_token 开发者需要进行妥善保存 access_token 的存储至少要保留 512 个字符空间 access_token 的有效期目前为 2 个小时, 需定时刷新, 重复

OPPO 推送平台服务端 API 修订记录 : 版本号修订人修订日期修订描述 V0.1 宫建涛 初始版本 V0.2 宫建涛 部分 API 修改 V0.3 宫建涛 修改返回码 V0.4 宫建涛 修改推送统计接口 V

此文章将会根据不同厂商的 SDK 的接入方式逐步分析, 进而梳理出最为精简的接入方式, 同时说明各个接入配置的细节问题 一接入准备工作 关于组件的基本配置将会全部打包到 aar 中的 AndroidManifest 中, 用户只需要手动配置一些与包名相关的权限配置 1.1 小米 混淆配置 基于 aa

停止混流接口 请注意 : 该功能需要联系 ZEGO 技术支持开通 1 接口调用说明 http 请求方式 : POST/FORM, 需使用 https 正式环境地址 access_token=access_token (http

集成推送平台 PushSDK 设计文档 此文档在于向开发者介绍魅族统一推送平台 PushSDK 如何对各个厂家的 PushSDK 进行整合以及我们在统一接口设计中遵循的规则, 由于各个厂家的 API 接口功能差异巨大我们只对各个厂商共用的接口进行统一封装, 当然你也可以直接使用厂商提供的接口 Ups

新・解きながら学ぶJava

在设备联网情况下, 到达率可达到 99.9% 三 基本架构 四 组件说明 Push Service:Flyme OS 上的一个常驻系统服务, 在网络可达的情况下时刻保持与推送服务器的长连接 Push SDK: 用于接收 Push Service 透传过来的消息并回调给应用, 它包括 Android

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基

新美大酒店开放平台SDK(.NET版)使用说明.pages

Microsoft Word - 01.DOC

3.1 num = 3 ch = 'C' 2

魅族推送平台接入文档 (Push-Demo)

1.JasperReport ireport JasperReport ireport JDK JDK JDK JDK ant ant...6

优斗士微分销产品使用指南

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

云数据库 RDS SDK

EJB-Programming-3.PDF

Guava学习之Resources

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

概述

EJB-Programming-4-cn.doc

威 福 髮 藝 店 桃 園 市 蘆 竹 區 中 山 里 福 祿 一 街 48 號 地 下 一 樓 50,000 獨 資 李 依 純 105/04/06 府 經 登 字 第 號 宏 品 餐 飲 桃 園 市 桃 園 區 信 光 里 民

1. 访 问 最 新 发 行 公 告 信 息 jconnect for JDBC 访 问 最 新 发 行 公 告 信 息 最 新 版 本 的 发 行 公 告 可 以 从 网 上 获 得 若 要 查 找 在 本 产 品 发 布 后 增 加 的 重 要 产 品 或 文 档 信 息, 请 访

chp6.ppt

Microsoft PowerPoint - 05-Status-Codes-Chinese.ppt



RxJava

API参考

untitled

CHAPTER 1

untitled

雲端 Cloud Computing 技術指南 運算 應用 平台與架構 10/04/15 11:55:46 INFO 10/04/15 11:55:53 INFO 10/04/15 11:55:56 INFO 10/04/15 11:56:05 INFO 10/04/15 11:56:07 INFO

Java

}; "P2VTKNvTAnYNwBrqXbgxRSFQs6FTEhNJ", " " string imagedata; if(0!= read_image("a.jpg",imagedata)) { return -1; } string rsp; ytopen_sdk m_sd

Microsoft Word - 第3章.doc

Java Access 5-1 Server Client Client Server Server Client 5-2 DataInputStream Class java.io.datainptstream (extends) FilterInputStream InputStream Obj

PowerPoint 演示文稿

Http Method GET Http 返回格式 JSON Http 请求参数说明 参数类型是否必需描述 userid string 否用户 id imei string 否用户手机 IMEI 号 cid string 否用户网站 cookieid( 注意 :userid imei cid 至少包

团 学 要 闻 我 校 召 开 共 青 团 五 届 九 次 全 委 ( 扩 大 ) 会 议 3 月 17 日, 我 校 共 青 团 五 届 九 次 全 委 ( 扩 大 ) 会 议 在 行 政 办 公 楼 五 楼 会 议 室 举 行, 校 团 委 委 员 各 院 ( 系 ) 团 委 书 记 校 学 生

Java java.lang.math Java Java.util.Random : ArithmeticException int zero = 0; try { int i= 72 / zero ; }catch (ArithmeticException e ) { // } 0,

概述

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

エスポラージュ株式会社 住所 : 東京都江東区大島 東急ドエルアルス大島 HP: ******************* * 关于 Java 测试试题 ******

1.5招募说明书(草案)

其他服务API文档

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID

電機工程系認可證照清單 /7/1

参数管理接口API文档

目 录 第 一 部 分 档 案 局 概 况 一 主 要 职 责 二 部 门 决 算 单 位 构 成 第 二 部 分 档 案 局 2016 年 度 部 门 预 算 表 一 2016 年 度 市 级 部 门 收 支 预 算 总 表 二 2016 年 度 市 级 部 门 支 出 预 算 表 三 2016

2015 年 度 收 入 支 出 决 算 总 表 单 位 名 称 : 北 京 市 朝 阳 区 卫 生 局 单 位 : 万 元 收 入 支 出 项 目 决 算 数 项 目 ( 按 功 能 分 类 ) 决 算 数 一 财 政 拨 款 一 一 般 公 共 服 务 支 出 二

南華大學數位論文

國家圖書館典藏電子全文

本章学习目标 小风 Java 实战系列教程 SpringMVC 简介 SpringMVC 的入门案例 SpringMVC 流程分析 配置注解映射器和适配器 注解的使用 使用不同方式的跳转页面 1. SpringMVC 简介 Spring web mvc

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入

使用Cassandra和Spark 2.0实现Rest API服务

09 (File Processes) (mkdir) 9-3 (createnewfile) 9-4 (write) 9-5 (read) 9-6 (deletefile) 9-7 (deletedir) (Exercises)

untitled

JavaIO.PDF

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

chap07.key

云搜

获取 Access Token 1 基础概念 access_token 是接口的全局唯一票据, 接入方调用各接口时都需使用 access_token 开发者需要妥善保存,access_token 的存储至少要保留 512 个字符空间 access_token 的有效期目前为 2 个小时, 需定时刷新

untitled

mvc

<4D F736F F F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074>

ebook 86-15

Microsoft Word - Learn Objective-C.doc

硬件令牌集成方式介绍

javaexample-02.pdf

Microsoft Word - 个推平台服务端MMP接口文档-v1.010.docx

DU Ad Platform_SDK 安卓接入指南 DU Ad Platform_SDK for Android 接入手册 ( 触发式广告 ) DUAd_SDK_Trigger v1.0 百度在线网络技术 ( 北京 ) 有限公司 百度在线网络技术 ( 北京 ) 有限公司 - 1 -

TC35短信发送程序设计

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2

拉卡拉云POS终端收单支付应用组件调用接口说明

<4D F736F F D20D6D0CEC4B7A88C57B454CABF8C57CEBBD593CEC4D28EB9A0>

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 ->

INTRODUCTION TO COM.DOC

公務員服務法第13條相關解釋彙整表

资 讯 速 递 台 基 于 大 数 据 的 学 校 督 导 评 估 系 统 建 设 上 海 市 闵 行 区 人 民 政 府 教 育 督 导 室 ( 摘 要 ) 闵 行 教 育 在 深 化 教 育 改 革 探 索 管 办 评 分 离 的 背 景 下, 把 教 育 督 导 评 估 系 统 建 设 作 为

浙江师范大学2014年度毕业生就业质量报告

目 录 监 管 资 讯 2016 年 全 国 保 险 监 管 工 作 会 议 召 开...3 协 会 动 态 赤 峰 保 险 行 业 协 会 召 开 数 据 统 计 和 信 息 宣 传 总 结 表 彰 会 议...5 赤 峰 市 保 险 行 业 协 会 秘 书 处 召 开 2015 年 度 述 职

同 时, 采 取 提 供 新 闻 线 索 和 素 材 安 排 专 访 等 方 式 主 动 为 新 闻 媒 体 服 务, 为 采 访 报 道 活 动 创 造 便 利 条 件 建 设 网 络 信 息 发 布 平 台 2013 年 9 月 开 通 中 央 纪 委 监 察 部 网 站,2015 年 1 月

大陸教育部等6個部門公佈「現代職業教育體系建設規劃 ( 年)」規劃到2015年初步形成現代職業教育體系框架,到2020年基本建成「中國」特色現代職業教育體系

B1

時間軸上的竹蓮記憶 學務主任 黃雅彙 我不是竹蓮國小的畢業校友 但對於身為新竹人的我來 說 仔細回想起來 似乎和竹蓮有著一種特別的緣分 對竹蓮國小最初的印象是在小學的時候 猶記得年幼的 我經過一段時日的啦啦隊舞蹈訓練後 老師便帶著我們從學 校步行到竹蓮國小來參加比賽 一踏入竹蓮校門 映入眼簾 的是黑

B1

Microsoft Word - 临政办发6.doc

untitled

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

<453A5CCEC4B5B55C C41CBAAB2F5D4C6BDD3BFDACAB9D3C3CBB5C3F756312E305F E646F63>

( Version 0.4 ) 1

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

untitled

Transcription:

魅族推送平台接入文档 (JAVA-SDK) 2017.02

文档变更记录 日期作者版本变更描述下载链接 2016-12-18 王新国 1.0.0.20161218_release 1.0.0 标准版 Download 2017-02-16 王新国 1.1.0.20170216_release 1.1.0 标准版 Download 2

目录 魅族推送平台接入文档 (JAVA-SDK)... 1 1. 类型定义... 5 1.1 推送服务 (IFlymePush)... 5 1.2 通知栏消息体 (Message)... 5 1.2.1 通知栏消息 (VarnishedMessage)... 5 1.2.2 透传消息 (UnVarnishedMessage)... 9 1.3 接口返回值 (ResultPack)... 10 1.4 消息推送结果 (PushResult)... 11 1.5 接口响应码定义 (ErrorCode)... 11 1.6 推送响应码定义 (PushResponseCode)... 12 1.7 推送类型 (PushType)... 13 1.8 推送标签集合类型 (ScopeType)... 13 1.9 任务推送统计 (TaskStatistics)... 14 2. 接口说明... 14 2.1 非任务推送... 14 2.1.1 描述... 14 2.1.2 应用场景... 14 2.1.2.1 pushid 通知栏消息推送 (pushmessage)... 15 2.1.2.2 pushid 透传消息推送 (pushmessage)... 17 2.1.2.3 别名通知栏消息推送 (pushmessagebyalias)... 19 2.1.2.4 别名透传消息推送 (pushmessagebyalias)... 21 3

2.2 任务推送... 23 2.2.1 描述... 23 2.2.2 应用场景... 23 2.2.3 获取推送 taskid(gettaskid)... 24 2.2.4 pushid 消息推送 (pushmessagebytaskid)... 25 2.2.5 别名消息推送 (pushaliasmessagebytaskid)... 28 2.2.6 应用全部推送 (pushtoapp)... 31 2.2.7 应用标签推送 (pushtotag)... 33 2.2.8 取消推送任务 (canceltaskpush)... 34 2.3 推送统计... 35 获取任务推送统计 (gettaskstatistics)... 35 4

1. 类型定义 1.1 推送服务 (IFlymePush) 调用该类实例的方法来推送消息, 构造函数说明如下 : 参数名称类型必填默认描述 appsecret String 是 null 注册应用 appsecret usessl Boolean 否 false 是否使用 https 接口调用 :true 使 用 https 连接,false 使用 http 连接 1.2 通知栏消息体 (Message) 推送消息实体 ( 抽象类 ): 子类 说明 VarnishedMessage 通知栏消息体 UnVarnishedMessage 透传消息体 1.2.1 通知栏消息 (VarnishedMessage) 参数名称类型必填默认描述 appid Long 是 null 注册应用 appid title String 是 null 推送标题, ( 字数限制 1~32) content String 是 null 推送内容, ( 字数限制 1~100) 5

参数名称类型必填默认描述 通知栏样式 (0, " 标准 "),(2, " noticebartype int 否 0 安卓原生 ")( 非必填, 默认 值为 0) 展开方式 (0, " 标准 "),(1, " noticeexpandtype int 否 0 文本 ")( 非必填, 默认值为 0) noticeexpandcont ent String 否 null 展开内容, (noticeexpandtype 为文 本时, 必填 ) 点击动作 (0," 打开应用 "),(1," 打开应用页面 "),(2," 打 clicktype int 否 0 开 URI 页面 "),(3, " 应用客户 端自定义 ")( 非必填, 默认 值为 0) URI 页面地址, (clicktype url String 否 null 为打开 URI 页面时, 必填, 长度限制 1000byte) parameters JSONOb ject 否 null 透传参数 (JSON 格式, 非必填 ) 6

参数名称类型必填默认描述 应用页面地址, (clicktype activity String 否 null 为打开应用页面时, 必填, 长度限制 1000byte) 应用客户端自定义内容, customattribute String 否 null (clicktype 为应用客户端 自定义时, 必填, 长度限制 1000byte) 是否进离线消息, (false 否 isoffline Boolean 否 true true 是 ) ( 非必填, 默认 值为 true) 有效时长 (1~72 小时内的 validtime int 否 24 正整数 ), (isoffline 值为 true 时, 必填, 值的范围 1~72) 定时推送 (0, " 即时 "),(1, " pushtimetype int 否 0 定时 "), ( 只对全部用户推 送生效 ) starttime Date 否 null 任务定时开始时间,( 非必 填,pushTimeType 为 7

参数名称类型必填默认描述 True 必填 ) 只对全部用户 推送生效 isfixspeed Boolean 否 false 是否定速推送, ( 非必填, 默认值为 False) fixspeedrate Long 否 0 定速速率,(isFixSpeed 为 true 时, 必填 ) 是否通知栏悬浮窗显示 issuspend Boolean 否 true (true 显示,false 不显示 ) ( 非必填, 默认 True) 是否可清除通知栏 (true 可 isclearnoticebar Boolean 否 true 以,false 不可以 ),( 非 必填, 默认 true) isfixdisplay Boolean 否 false 是否定时展示 ( 非必填, 默 认 false) fixdisplaytime (Date,D ate) 否 (null,null ) 定时展示开始, 结束时间 (fixdisplay 为 true 时, 必填, 并且开始时间要晚于结束时间 ) 8

参数名称类型必填默认描述 震动 (false 关闭 true 开 vibrate Boolean 否 true 启 ), ( 非必填, 默认 true) 闪光 (false 关闭 true 开 lights Boolean 否 true 启 ), ( 非必填, 默认 true) 声音 (false 关闭 true 开 sound Boolean 否 true 启 ), ( 非必填, 默认 true) 1.2.2 透传消息 (UnVarnishedMessage) 参数名称类型必填默认描述 appid Long 是 null 注册应用 appid title String 否 null 推送标题, 任务推送建议填写, 方便 数据查询,( 字数限制 1~32) content String 是 null 推送内容,( 必填, 字数限制 3800byte 以内 ) isoffline Boolean 否 true 是否进离线消息,( 非必填, 默认为 true) 9

参数名称类型必填默认描述 有效时长 (1~72 小时内的正整数 ), validtime int 否 24 (isoffline 值为 true 时, 必填, 值的范围 1--72) pushtimet ype int 否 0 定时推送 (0, " 即时 "),(1, " 定时 "), ( 只对全部用户推送生效 ) 任务定时开始时间, starttime Date 否 null (pushtimetype 为 1 必填 ) 只对 全部用户推送生效 isfixspeed Boolean 否 false 是否定速推送,( 非必填, 默认值为 false) fixspeedra te Long 否 0 定速速率 (isfixspeed 为 true 时, 必填 ) 1.3 接口返回值 (ResultPack) 方法名称类型描述 code() String 接口响应码 Comment() String 接口响应描述 value() T 接口响应内容 10

方法名称类型描述 errorcode() Enum 接口响应异常枚举详见 ErrorCode 1.4 消息推送结果 (PushResult) 方法名称类型描述 getmsgid() String 推送消息 ID, 用于推送流程明细排查 getresptarget() Map 推送目标结果状态 (KEY: 推送响应码 VALUE: 响应码对应的目标用户 ) 1.5 接口响应码定义 (ErrorCode) 名称 Code Commen UNKNOWN_ERROR -1 未知错误 SUCCESS 200 成功 SYSTEM_ERROR 1001 系统错误 SYSTEM_BUSY 1003 服务器忙 PARAMETER_ERROR 1005 参数错误, 请参考 API 文档 INVALID_SIGN 1006 签名认证失败 INVALID_APPLICATION_ID 110000 appid 不合法 11

名称 Code Commen INVALID_APPLICATION_KEY 110001 appkey 不合法 UNSUBSCRIBE_PUSHID 110002 pushid 未注册 INVALID_PUSHID 110003 pushid 非法 PARAM_BLANK 110004 参数不能为空 APP_IN_BLACK_LIST 110009 应用被加入黑名单 APP_REQUEST_EXCEED_LIMIT 110010 应用请求频率过快 APP_PUSH_TIME_EXCEED_LIMIT 110051 超过该应用的次数限制 APP_REQUEST_PUSH_LIMIT 110019 超过该应用每天推送次 数限制 INVALID_APPLICATION_PACKAGE NAME 110031 packagename 不合法 INVALID_TASK_ID 110032 非法的 taskid INVALID_APPLICATION_SECRET 110033 非法的 appsecret 1.6 推送响应码定义 (PushResponseCode) 名称 Code Commen RSP_NO_AUT 201 没有权限, 服务器主动拒绝 12

名称 Code Commen RSP_DB_ERROR 501 推送消息失败 (db_error) RSP_INTERNAL_ERROR 513 推送消息失败 RSP_SPEED_LIMIT 518 推送超过配置的速率 RSP_OVERFLOW 519 推送消息失败服务过载 RSP_REPEATED 520 消息折叠 (1 分钟内同一设备同一应用消 息收到多次, 默认 5 次 ) RSP_UNSUBSCRIBE_PU SHID 110002 pushid 未订阅 ( 包括推送开关关闭的设 备 ) RSP_INVALID_PUSHID 110003 pushid 非法 RSP_UNSUBSCRIBE_ALI AS 110005 别名未订阅 ( 包括推送开关关闭的设备 ) 1.7 推送类型 (PushType) 枚举类型描述 STATUSBAR Enum 通知栏消息类型 DIRECT Enum 透传消息类型 1.8 推送标签集合类型 (ScopeType) 13

枚举类型描述 UNION Enum 并集 INTERSECTION Enum 交集 1.9 任务推送统计 (TaskStatistics) 名称类型描述 targetno Long 目标数 validno Long 有效数 pushedno Long 推送数 acceptno Long 接受数 displayno Long 展示数 2. 接口说明 2.1 非任务推送 2.1.1 描述 向指定的 pushid 推送消息 : clickno Long 点击数 注 : 推送平台使用 pushid 来标识每个独立的用户, 每一台终端上每一个 app 拥有一个独立的 pushid 2.1.2 应用场景 场景 1: 查找手机业务需要远程定位位置, 可发送消息指令到对应的设备 14

场景 2: 社区用户回帖消息提醒, 用户对发表的帖子有最新回复时, 消息提醒发帖者 2.1.2.1 pushid 通知栏消息推送 (pushmessage) 接口说明 : 接口 说明 ResultPack< PushResult> pushmessage(varnishedmessage message, List<String> pushids) ResultPack< PushResult > pushmessage(varnishedmessage message, List<String> pushids, int retries) 推送通知栏消息 推送通知栏消息 参数说明 : 参数名称类型必需默认描述 message VarnishedMessage 是 null 推送消息 pushids List 是 null 推送目标, 一批最多不 能超过 1000 个 retries int 否 0 超时 or 异常重试次数 返回值 : PushResult msgid; 推送消息 ID, 用于推送流程明细排查 resptarget; 推送目标结果状态 (key: 推送响应码 value: 响应码对应的目标用户注 : 只返回不合法 超速以及推送失败的目标用户, 业务一般对超速的 pushid 处理 示例 : /** * 通知栏消息推送 (pushmessage) * @throws Exception */ @Test public void testvarnishedmessagepush() throws Exception { 15

// 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 组装消息 VarnishedMessage message = new VarnishedMessage.Builder().appId(appId).title("Java SDK 推送标题 ").content("java SDK 推送内容 ").noticeexpandtype(1).noticeexpandcontent(" 展开文本内容 ").clicktype(2).url("http://www.baidu.com").parameters(json.pa rseobject("{\"k1\":\"value1\",\"k2\":0,\"k3\":\"value3\"")).offline(true).validtime(12).suspend(true).clearnoticebar(true).vibrate(true).lights(tru e).sound(true).build(); // 目标用户 List<String> pushids = new ArrayList<String>(); pushids.add("pushid_1"); pushids.add("pushid_2"); // 1 调用推送服务 ResultPack< PushResult> result = push.pushmessage(message, pushids); if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... 16

else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); 2.1.2.2 pushid 透传消息推送 (pushmessage) 接口说明 : 接口 说明 ResultPack<PushResult> pushmessage(unvarnishedmessage message, List<String> pushids) ResultPack<PushResult> pushmessage(unvarnishedmessage message, List<String> pushids, int retries) 推送透传消息 推送透传消息 参数说明 : 参数名称类型必需默认描述 message UnVarnishedMessage 是 null 推送消息 pushids List 是 null 推送目标, 一批最多不能 超过 1000 个 retries int 否 0 超时 or 异常重试次数 返回值 : PushResult msgid; 推送消息 ID, 用于推送流程明细排查 resptarget; 推送目标结果状态 (key: 推送响应码 value: 响应码对应的目标用户注 : 只返回不合法 超速以及推送失败的目标用户, 业务一般对超速的 pushid 处理 示例 : /** 17

* 透传消息推送 (pushmessage) * @throws Exception */ @Test public void testunvarnishedmessagepush() throws Exception { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 组装透传消息 UnVarnishedMessage message = new UnVarnishedMessage.Builder().appId(appId).title("Java SDK 透传推送标题 ").content("java Sdk 透传推送内容 ").isoffline(true).validtime(10).build(); // 目标用户 List<String> pushids = new ArrayList<String>(); pushids.add("pushid_1"); pushids.add("pushid_2"); // 1 调用推送服务 ResultPack<PushResult> result = push.pushmessage(message, pushids); if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... 18

else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); 2.1.2.3 别名通知栏消息推送 (pushmessagebyalias) 接口说明 : 接口 说明 ResultPack<PushResult> pushmessagebyalias(varnishedmessage message, List<String> alias) ResultPack<PushResult> pushmessagebyalias(varnishedmessage message, List<String> alias, int retries) 推送通知栏消息 推送通知栏消息 参数说明 : 参数名称类型必需默认描述 message VarnishedMessage 是 null 推送消息 alias List 是 null 推送目标, 一批最多不 能超过 1000 个 retries int 否 0 超时 or 异常重试次数 返回值 : PushResult msgid; 推送消息 ID, 用于推送流程明细排查 resptarget; 推送目标结果状态 (key: 推送响应码 value: 响应码对应的目标用户注 : 只返回不合法 超速以及推送失败的目标用户, 业务一般对超速的 pushid 处理 示例 : 19

/** * 别名通知栏消息推送 (pushmessage) * * @throws Exception */ @Test public void testvarnishedmessagepushbyalias() throws Exception { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 组装消息 VarnishedMessage message = new VarnishedMessage.Builder().appId(appId).title("Java SDK 推送标题 ").content("java SDK 推送内容 ").noticeexpandtype(1).noticeexpandcontent(" 展开文本内容 ").clicktype(2).url("http://push.meizu.com").parameters(json.parse Object("{\"k1\":\"value1\",\"k2\":0,\"k3\":\"value3\"")).offLine(true).validTime(12).isFixDisplay(true).fixDisplayTime(str2Date("2017-10-01 12:00:00"), str2date("2017-10-01 12:30:00")).suspend(true).clearNoticeBar(true).vibrate(true).lights(true).s ound(true).build(); // 目标用户 List<String> alias = new ArrayList<String>(); alias.add("android"); alias.add("alias2"); // 1 调用推送服务 ResultPack<PushResult> result = push.pushmessagebyalias(message, alias); if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target 20

if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); 2.1.2.4 别名透传消息推送 (pushmessagebyalias) 接口说明 : 接口 说明 ResultPack<PushResult> pushmessagebyalias(unvarnishedmessage message, List<String> alias) ResultPack<PushResult> pushmessagebyalias(unvarnishedmessage message, List<String> alias, int retries) 推送透传消息 推送透传消息 参数说明 : 参数名称 类型 必 需 默 认 描述 message UnVarnishedMessage 是 null 推送消息 21

参数名称 类型 必 需 默 认 描述 alias List 是 null 推送目标, 一批最多不能 超过 1000 个 retries int 否 0 超时 or 异常重试次数 返回值 : PushResult msgid; 推送消息 ID, 用于推送流程明细排查 resptarget; 推送目标结果状态 (key: 推送响应码 value: 响应码对应的目标用户注 : 只返回不合法 超速以及推送失败的目标用户, 业务一般对超速的 pushid 处理 示例 : /** * 别名透传推送 * * @throws Exception */ @Test public void testunvarnishedmessagepushbyalias() throws Exception { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 组装透传消息 UnVarnishedMessage message = new UnVarnishedMessage.Builder().appId(appId).title("Java SDK 透传推送标题 ").content("java Sdk 透传推送内容 ").build(); // 目标用户 List<String> alias = new ArrayList<String>(); alias.add("alias"); alias.add("alias2"); alias); // 1 调用推送服务 ResultPack<PushResult> result = push.pushmessagebyalias(message, 22

if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); 2.2 任务推送 2.2.1 描述 首先获取推送的 taskid, 然后通过 taskid 向指定的 pushid 推送消息 2.2.2 应用场景 浏览器对指定的某一大批量 pushid 用户推送活动或者新闻消息, 通过先获取 taskid, 然后通过 taskid 批量推送, 推送过程中可以根据 taskid 时时获取推送 统计结果 23

2.2.3 获取推送 taskid(gettaskid) 接口说明 : 接口 说明 ResultPack gettaskid(pushtype pushtype, Message message) 获取推送 taskid 参数说明 : 参数名称类型必需默认描述 pushtype PushType 是 null 消息类型 message Message 是 null 消息体 返回值 : Long 任务 ID 示例 : /** * 获取通知栏推送 taskid(gettaskid) * @throws Exception */ @Test public void testgetvarnishedmessagetaskid() throws Exception { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 组装消息 VarnishedMessage message = new VarnishedMessage.Builder().appId(appId).title("java Sdk 推送标题 ").content("java Sdk 推送内容 ").noticeexpandtype(1).noticeexpandcontent(" 展开文本内容 ").clicktype(2).url("http://www.baidu.com").parameters(json.pa rseobject("{\"k1\":\"value1\",\"k2\":0,\"k3\":\"value3\"")).offline(true).validtime(12) 24

.suspend(true).clearnoticebar(true).vibrate(false).lights(fa lse).sound(false).fixspeed(true).fixspeedrate(20).build(); ResultPack<Long> result = push.gettaskid(pushtype.statusbar, message); System.out.println(result); /** * 获取透传推送 taskid(gettaskid) * @throws Exception */ @Test public void testgetunvarnishedmessagetaskid() throws Exception { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 组装消息 UnVarnishedMessage message = new UnVarnishedMessage.Builder().appId(appId).title("java sdk 推送标题 ").content("java sdk 推送内容 ").build(); ResultPack<Long> result = push.gettaskid(pushtype.direct, message); System.out.println(result); 2.2.4 pushid 消息推送 (pushmessagebytaskid) 接口说明 接口 说明 ResultPack<PushResult> pushmessagebytaskid(pushtype pushtype, long appid, long taskid, List<String> pushids) 任务消息推 送 ResultPack<PushResult> pushmessagebytaskid(pushtype pushtype, long appid, long taskid, List<String> pushids, int retries) 任务消息推 送 25

参数说明 : 参数名称类型必需默认描述 pushtype PushType 是 null 消息类型 appid Long 是 null 推送应用 ID taskid Long 是 null 推送任务 ID pushids List 是 null 推送目标, 一批最多不能超过 1000 个 retries int 否 0 超时 or 异常重试次数 返回值 : PushResult msgid; 推送消息 ID, 用于推送流程明细排查 resptarget; 推送目标结果状态 (key: 推送响应码 value: 响应码对应的目标用户注 : 只返回不合法 超速以及推送失败的目标用户, 业务一般对超速的 pushid 处理 示例 : /** * 任务消息推送 (pushmessagebytaskid) * @throws IOException */ @Test public void testpushpytaskid() throws IOException { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 目标用户 List<String> pushids = new ArrayList<String>(); pushids.add("pushid_1"); pushids.add("pushid_2"); // 通知栏任务消息推送 Long taskid = 123l; // 1 调用推送服务 26

ResultPack<PushResult> result = push.pushmessagebytaskid(pushtype.statusbar, appid, taskid, pushids, 0); if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); // 透传消息任务推送 taskid = 123l; // 1 调用推送服务 result = push.pushmessagebytaskid(pushtype.direct, appid, taskid, pushids, 0); if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 27

Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); 2.2.5 别名消息推送 (pushaliasmessagebytaskid) 接口说明 : 接口 说明 ResultPack<PushResult> pushaliasmessagebytaskid(pushtype pushtype, long appid, long taskid, List<String> alias) ResultPack<PushResult> pushaliasmessagebytaskid(pushtype pushtype, long appid, long taskid, List<String> alias, int retries) 任务消息推送 任务消息推送 参数说明 : 28

参数名称类型必需默认描述 pushtype PushType 是 null 消息类型 appid Long 是 null 推送应用 ID taskid Long 是 null 推送任务 ID alias List 是 null 推送目标别名, 一批最多 不能超过 1000 个 retries int 否 0 超时 or 异常重试次数 返回值 : PushResult msgid; 推送消息 ID, 用于推送流程明细排查 resptarget; 推送目标结果状态 (key: 推送响应码 value: 响应码对应的目标用户注 : 只返回不合法 超速以及推送失败的目标用户, 业务一般对超速的 pushid 处理 示例 : ** * 别名任务消息推送 * * @throws IOException */ @Test public void testpushaliaspytaskid() throws IOException { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 目标用户 List<String> alias = new ArrayList<String>(); alias.add("alias123"); alias.add("android654"); // 通知栏任务消息推送 Long taskid = 45361L; // 1 调用推送服务 29

ResultPack<PushResult> result = push.pushaliasmessagebytaskid(pushtype.statusbar, appid, taskid, alias); if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); // 透传消息任务推送 taskid = 45407L; // 1 调用推送服务 result = push.pushaliasmessagebytaskid(pushtype.direct, appid, taskid, alias); if (result.issucceed()) { // 2 调用推送服务成功 ( 其中 map 为设备的具体推送结果, 一般业务针对超速的 code 类型做处理 ) PushResult pushresult = result.value(); String msgid = pushresult.getmsgid();// 推送消息 ID, 用于推送流程明细排查 30

Map<Integer, List<String>> targetresultmap = pushresult.getresptarget();// 推送结果, 全部推送成功, 则 map 为 empty System.out.println("push msgid:" + msgid); System.out.println("push targetresultmap:" + targetresultmap); if (targetresultmap!= null &&!targetresultmap.isempty()) { // 3 判断是否有获取超速的 target if (targetresultmap.containskey(pushresponsecode.rsp_speed_limit.getvalue())) { // 4 获取超速的 target List<String> ratelimittarget = targetresultmap.get(pushresponsecode.rsp_speed_limit.getvalue()); System.out.println("rateLimitTarget is :" + ratelimittarget); //TODO 5 业务处理, 重推... else { // 调用推送接口服务异常 eg: appid appkey 非法 推送消息非法... // result.code(); // 服务异常码 // result.comment();// 服务异常描述 System.out.println(String.format("pushMessage error code:%s comment:%s", result.code(), result.comment())); 2.2.6 应用全部推送 (pushtoapp) 接口说明 : 接口 ResultPack<Long> pushtoapp(pushtype pushtype, Message message) 说明 应用全部推送 参数说明 : 参数名称类型必需默认描述 pushtype PushType 是 null 消息类型 message Message 是 null 消息体 31

返回值 : Long 任务 ID 示例 : /** * 应用全部推送 (pushtoapp) * @throws IOException */ @Test public void testpushtoapp() throws IOException { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 通知栏全部消息推送 VarnishedMessage message = new VarnishedMessage.Builder().appId(appId).title("java Sdk 全部推送标题 ").content("java Sdk 全部推送内容 ").noticeexpandtype(1).noticeexpandcontent(" 展开文本内容 ").clicktype(2).url("http://www.baidu.com").parameters(json.pa rseobject("{\"k1\":\"value1\",\"k2\":0,\"k3\":\"value3\"")).offline(true).validtime(12).suspend(true).clearnoticebar(true).vibrate(false).lights(fa lse).sound(false).fixspeed(true).fixspeedrate(30).pushtimetype(1).starttime(new Date()).build(); ResultPack<Long> result = push.pushtoapp(pushtype.statusbar, message); System.out.println(result); // 透传全部推送 UnVarnishedMessage message2 = new UnVarnishedMessage.Builder().appId(appId).title("Java SDK 全部推送标题 ").content("java Sdk 全部推送内容 ").isoffline(true).validtime(10).pushtimetype(1).starttime(new Date()).build(); 32

result = push.pushtoapp(pushtype.direct, message2); System.out.println(result); 2.2.7 应用标签推送 (pushtotag) 接口说明 : 接口 说明 ResultPack<Long> pushtotag(pushtype pushtype, Message message, List<String> tagname, ScopeType scopetype) 应用标签推送 参数说明 : 参数名称类型必需默认描述 pushtype PushType 是 null 消息类型 message Message 是 null 消息体 tagname List 是 null 推送标签 scopetype ScopeType 是 null 标签集合类型 返回值 : Long 任务 ID 示例 : /** * 标签推送 (pushtotag) * * @throws IOException */ @Test public void testpushtotag() throws IOException { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); // 推送标签 List<String> tagname = new ArrayList<String>(); 33

tagname.add("news"); tagname.add("tech"); // 通知栏标签推送 VarnishedMessage varnishedmessage = new VarnishedMessage.Builder().appId(appId).title("java Sdk 标签推送标题 ").content("java Sdk 标签推送内容 ").noticeexpandtype(1).noticeexpandcontent(" 展开文本内容 ").offline(true).validtime(12).suspend(true).clearnoticebar(true).vibrate(false).lights(false).sound(false).fixspeed(true).fixspeedrate(30).pushtimetype(1).starttime(new Date()).build(); ResultPack<Long> result = push.pushtotag(pushtype.statusbar, varnishedmessage, tagname, ScopeType.INTERSECTION); System.out.println(result); // 透传标签推送 UnVarnishedMessage unvarnishedmessage = new UnVarnishedMessage.Builder().appId(appId).title("Java SDK 标签推送标题 ").content("java Sdk 标签推送内容 ").isoffline(true).validtime(10).pushtimetype(1).starttime(new Date()).build(); result = push.pushtotag(pushtype.direct, unvarnishedmessage, tagname, ScopeType.UNION); System.out.println(result); 2.2.8 取消推送任务 (canceltaskpush) 接口说明 : 接口 ResultPack<Boolean> canceltaskpush(pushtype pushtype, long appid, long taskid) 说明 只针对全部用户推送以及标签推送且推送状态为待推送或者推送中的任务取消 34

参数说明 : 参数名称 类型 必需 默认 描述 pushtype PushType 是 null 消息类型 appid Long 是 null 应用 ID taskid Long 是 null 任务 ID 返回值 : Boolean true: 成功 false: 失败 示例 : /** * 取消推送任务 (canceltaskpush) 只针对全网推送生效 * @throws IOException */ @Test public void testcanceltaskpush() throws IOException { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); long taskid = 123l; ResultPack resultpack = push.canceltaskpush(pushtype.statusbar, appid, taskid); System.out.println(resultPack); 2.3 推送统计 获取任务推送统计 (gettaskstatistics) 接口说明 : 接口 说明 public ResultPack<TaskStatistics> gettaskstatistics(long appid, long taskid) 获取推送统计 参数说明 : 35

参数名称类型必需默认描述 appid Long 是 null 应用 ID taskid Long 是 null 任务 ID 返回值 : TaskStatistics 示例 : /** * 获取任务统计结果 * * @throws IOException */ @Test public void testgettaskstatistics() throws IOException { // 推送对象 IFlymePush push = new IFlymePush(APP_SECRET_KEY); long taskid = 44760L; ResultPack<TaskStatistics> resultpack = push.gettaskstatistics(appid, taskid); System.out.println(resultPack); 36