极光的研究
来源:互联网 发布:python可以开发软件吗 编辑:程序博客网 时间:2024/04/29 13:05
1. 调用极光推送
List recList3 = new ArrayList();recList3.add(sc3);JPush.SendPushForAndroidAndIos(title, msgContent, null, recList3, JPush.Platforms.iTask);
这里的 sc3 ---- 就是 登录人登录在 app 的 账号 SA8@lsh.com
2.
1. 弹出的头2. 具体的信息 4.接收人 5. 平台(安卓 或者ios)
public static void SendPushForAndroidAndIos(String alert, String msg_content, JsonObject json, List reclist, Platforms platform) { ClientConfig clientConfig = ClientConfig.getInstance(); // 定义推送到哪个APP JPushClient jpushClient = new JPushClient(platform.getValue(), platform.getKey(), null, clientConfig); // 推送对象 PushPayload payload = buildPushMsg(alert, msg_content, json, reclist); try { // 推送动作 PushResult result = jpushClient.sendPush(payload); logger.info("Got result - " + result); } catch (APIConnectionException e) { logger.error("Connection error. Should retry later. ", e); } catch (APIRequestException e) { logger.error("Error response from JPush server. Should review and fix it. ", e); logger.info("HTTP Status: " + e.getStatus()); logger.info("Error Code: " + e.getErrorCode()); logger.info("Error Message: " + e.getErrorMessage()); logger.info("Msg ID: " + e.getMsgId()); }}
3.推送对象
/** * @param alert 消息推送的消息头? * @param msg_content 消息内容 * @param json 对方解析extra时候约定的参数和值 * @param reclist 推送对象 * @return */ public static PushPayload buildPushMsg(String alert, String msg_content, JsonObject json, List reclist) { return PushPayload.newBuilder() .setPlatform(Platform.all()) .setAudience(Audience.alias(reclist)) //接受人 .setNotification(Notification.newBuilder() .addPlatformNotification(IosNotification.newBuilder() .setAlert(alert) .setBadge(5) .setSound("happy") .addExtra("data", json) .build()) .addPlatformNotification(AndroidNotification.newBuilder() .setAlert(alert) .build()) .build()) .setMessage(Message.content(msg_content)) .setOptions(Options.newBuilder() // 项目后期可能会更改为true// .setApnsProduction(true) .setApnsProduction(false) .build()) .build(); }
4. 平台 参数 包括在 极光上注册获得 的参数,一个 枚举的 内部类
public enum Platforms { iTask(iTaskAppKey, iTaskMasterSecret), iMgt(iMgtAppKey, iMgtMasterSecret); private String key; private String value; private Platforms(String key, String value) { this.key = key; this.value = value; } public String getKey() { return key; } public void setKey(String key) { this.key = key; } public String getValue() { return value; } public void setValue(String value) { this.value = value; }}
5.这是 极光获 的 参数
// iTask相关属性private static final String iTaskAppKey = "eb61318960e222d928a3f8dc";private static final String iTaskMasterSecret = "844e42ec8c7bf0fc86978508";// iManagement相关属性private static final String iMgtAppKey = "0bd0b1607288b9644c508789";private static final String iMgtMasterSecret = "673b586c3fe66227512c86f1";
0 0
- 极光的研究
- 极光空间研究组成立
- 耶洛奈夫上空的极光
- 美丽的极光
- 极光推送的使用方法
- 极光推送的设置
- 极光推送的API
- 极光推送的使用
- 极光推送的使用
- 极光推送的使用
- 极光推送的使用
- 极光推送的常见问题
- 极光推送的经验总结
- 极光推送的集成
- 极光推送的步骤
- 极光推送的集成
- 极光推送的集成
- 简单的极光推送
- PHP面向对象编程(二)
- Java生成CRC16数据校验码
- Android 同步机制
- IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.
- 常见设计模式
- 极光的研究
- SQL注入攻击高级
- 在VIM中进行文本替换:
- Gradle直接下载失败连接超时问题
- 【杂文随笔】2016年总结 送自己一个字
- YOLO源码详解(四)- 反向传播(back propagation)
- xml。。。json。。。object之间转化
- 系统内存占用
- Mysql命令create table:创建数据表