記錄騰訊信鴿推送服務java

1.獲取須要發送的信息json

Map person = getPersonOrg(PERSONUUID);
			String Id= (String) person.get("USERID");
			Id = Id == null ? "" : Id.trim();
			List<String> List = StringUtils.str2List(Id);
			Map<String, Object> tMap = new HashMap<String, Object>();
			tMap.put("msgType", "new_lraderTask");
			tMap.put("msg", "您有一條待任務");
			tMap.put("msgId",ddd);
			tMap.put("msgTo", Id);
			demoPushAccountList(List, "", tMap);

2.騰訊信鴿推送服務方法code

/**
	 * @note 騰訊信鴿推送服務
	 * @author 
	 * @date 2016-07-2
	 * @param accountList 推送賬號列表
	 * @param title 標題
	 * @param custom 自定義參數
	 * @return 推送結果
	 */
	public org.json.JSONObject demoPushAccountList(List<String> accountList, String title, Map<String, Object> custom) {
		org.json.JSONObject ret =new org.json.JSONObject();
		try {
		String accessIdStr = Configuration.getString("ACCESS_ID");// 目標應用ID
		int accessIdInt = Integer.parseInt(accessIdStr);
		String secretKey = Configuration.getString("SECRET_KEY");// 目標應用密鑰
		XingeApp xinge = new XingeApp(accessIdInt, secretKey);
		Message message = new Message();
		message.setTitle(title);
		message.setContent("");
		message.setType(Message.TYPE_MESSAGE);
		message.setCustom(custom);
		message.setMultiPkg(1);
		 ret = xinge.pushAccountList(0, accountList, message);
		} catch (Exception e) {
			LogUtil.error(e);
		}
		return (ret);
	}

3.jar包get

XingeApp.jarit

相關文章
相關標籤/搜索