From 5e7b0ed4a154ad067cbcf4aa1a1c7cce32f9864c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 26 四月 2024 18:02:17 +0800 Subject: [PATCH] 唯品会链接解析升级 --- fanli/src/main/java/com/yeshi/fanli/util/push/OPPOPushUtil.java | 693 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 346 insertions(+), 347 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/push/OPPOPushUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/push/OPPOPushUtil.java index c484612..ff48747 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/push/OPPOPushUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/push/OPPOPushUtil.java @@ -1,347 +1,346 @@ -package com.yeshi.fanli.util.push; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.yeshi.utils.annotation.MapUtil; - -import com.alibaba.fastjson.JSONObject; -import com.oppo.push.server.Notification; -import com.oppo.push.server.Result; -import com.oppo.push.server.Sender; -import com.oppo.push.server.Target; -import com.yeshi.fanli.entity.config.push.HWPushConfig; -import com.yeshi.fanli.exception.push.PushException; -import com.yeshi.fanli.service.inter.config.BusinessSystemService; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.taobao.TaoBaoUtil; - -@Component -public class OPPOPushUtil { - - private static OPPOPushUtil hWPushUtil; - - @Autowired - private BusinessSystemService businessSystemService; - - @PostConstruct - public void init() { - hWPushUtil = this; - hWPushUtil.businessSystemService = this.businessSystemService; - } - - private static String appkey = ""; - private static String masterSecret = ""; - - static { - Properties ps = org.yeshi.utils.PropertiesUtil - .getProperties(TaoBaoUtil.class.getClassLoader().getResourceAsStream("push_hw.properties")); - HWPushConfig config = (HWPushConfig) MapUtil.parseMap(HWPushConfig.class, ps); - appkey = config.getAppId(); - masterSecret = config.getAppSecret(); - } - - private static Map<String, String> getParams(String type, String activity, String url, String webUrl, Long id) { - Map<String, String> data = new HashMap<>(); - if (type != null) - data.put("type", type); - if (activity != null) - data.put("activity", activity); - if (url != null) - data.put("url", url); - if (webUrl != null) - data.put("webUrl", webUrl); - if (id != null) - data.put("id", id + ""); - return data; - } - - /** - * 鎺ㄩ�佸晢鍝� - * - * @param registerIds - * -鏈�澶у��1000 - * @param title - * @param content - * @param goodsType - * @param goodsId - * @throws PushException - */ - public static void pushGoods(List<String> registerIds, String title, String content, int goodsType, Long goodsId) - throws PushException { - if (registerIds != null && registerIds.size() > 100) - throw new PushException(1, "璁惧鏁颁笉鑳借秴杩�100涓�"); - - String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() - + ".ui.recommend.GoodsBrowserActivity"; - Map<String, String> params = getParams("goodsdetail", activity, null, null, goodsId); - - try { - boolean success = push(registerIds, title, content, params); - if (!success) - throw new PushException(2, "鎺ㄩ�佸け璐�"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 缃戦〉鎺ㄩ�� - * - * @param registerIds - * 鏈�澶у��1000 - * @param title - * @param content - * @param url - * -缃戦〉閾炬帴 - * @throws PushException - */ - public static void pushUrl(List<String> registerIds, String title, String content, String url) - throws PushException { - if (registerIds != null && registerIds.size() > 100) - throw new PushException(1, "璁惧鏁颁笉鑳借秴杩�1000涓�"); - - String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.invite.ShareBrowserActivity"; - Map<String, String> params = getParams("url", activity, null, url, null); - try { - boolean success = push(registerIds, title, content, params); - if (!success) - throw new PushException(2, "鎺ㄩ�佸け璐�"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 绔欏唴淇℃帹閫� - * - * @param registerIds - * 鏈�澶у��1000 - * @param title - * @param content - * @param url - * -缃戦〉閾炬帴 - * @throws PushException - */ - public static void pushZNX(List<String> registerIds, String title, String content) throws PushException { - if (registerIds != null && registerIds.size() > 100) - throw new PushException(1, "璁惧鏁颁笉鑳借秴杩�100涓�"); - Map<String, String> params = getParams("ZNX", null, null, null, null); - if (params == null) - return; - - try { - boolean success = push(registerIds, title, content, params); - if (!success) - throw new PushException(2, "鎺ㄩ�佸け璐�"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void pushWEEX(List<String> registerIds, String title, String content, String weexUrl) - throws PushException { - String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() - + ".ui.mine.weex.WeexApplicationActivity"; - Map<String, String> params = getParams("weex", activity, weexUrl, weexUrl, null); - if (params == null) - return; - - try { - boolean success = push(registerIds, title, content, params); - if (!success) - throw new PushException(2, "鎺ㄩ�佸け璐�"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void pushBaiChuanUrl(List<String> registerIds, String title, String content, String url) - throws PushException { - Map<String, String> params = getParams("baichuan", null, url, null, null); - if (params == null) - return; - - try { - boolean success = push(registerIds, title, content, params); - if (!success) - throw new PushException(2, "鎺ㄩ�佸け璐�"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void pushWelfareCenter(List<String> registerIds, String title, String content) throws PushException { - String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.WelfareCenterActivity"; - Map<String, String> params = getParams("welfare", activity, null, null, null); - if (params == null) - return; - - try { - boolean success = push(registerIds, title, content, params); - if (!success) - throw new PushException(2, "鎺ㄩ�佸け璐�"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void pushUserSignInNotification(List<String> registerIds, String title, String content) - throws PushException { - String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.goldtask.GoldTaskActivity"; - Map<String, String> params = getParams("signin", activity, null, null, null); - if (params == null) - return; - - try { - boolean success = push(registerIds, title, content, params); - if (!success) - throw new PushException(2, "鎺ㄩ�佸け璐�"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * - * @param list - * 鏈�澶т负1000 - */ - public static boolean push(List<String> list, String title, String content, Map<String, String> dataParams) { - Map<String, String> params = null; - if (dataParams != null) { - params = new HashMap<>(); - JSONObject json = new JSONObject(); - for (Iterator<String> its = dataParams.keySet().iterator(); its.hasNext();) { - String key = its.next(); - json.put(key, dataParams.get(key)); - } - params.put("data", json.toJSONString()); - } - - try { - Sender sender = new Sender("f14S6P4sCrW4gs0WCO80w80cW", "E7976fe3d1758bf0c3480d8DcE4236e2"); - Notification notifyCation = getNotification(title, content, - "com.yeshi.ec.rebate.myapplication.ui.OPPOPushMessageActivity", params); - if (list.size() == 1) { - Result result = sender.unicastNotification(notifyCation, Target.build(list.get(0))); - result.getStatusCode(); // 鑾峰彇http璇锋眰鐘舵�佺爜 - result.getReturnCode(); // 鑾峰彇骞冲彴杩斿洖鐮� - System.out.println(result.getStatusCode() + "-" + result.getReturnCode()); - if (result.getReturnCode().getCode() == 0) - return true; - else - return false; - } else { - Map<Target, Notification> batch = new HashMap<Target, Notification>(); // batch鏈�澶т负1000 - for (String registerId : list) { - batch.put(Target.build(registerId), notifyCation); - } - Result result = sender.unicastBatchNotification(batch); // 鍙戦�佹壒閲忓崟鎺ㄦ秷鎭� - result.getStatusCode(); // 鑾峰彇http璇锋眰鐘舵�佺爜 - result.getReturnCode(); // 鑾峰彇骞冲彴杩斿洖鐮� - System.out.println(result.getStatusCode() + "-" + result.getReturnCode()); - if (result.getReturnCode().getCode() == 0) - return true; - else - return false; - } - - // List<Result.UnicastBatchResult> batchResult = - // result.getUnicastBatchResults(); // 鎵归噺鍗曟帹缁撴灉 - // for (Result.UnicastBatchResult record : batchResult) { - // record.getErrorCode(); - // record.getErrorMessage(); - // record.getMessageId(); - // record.getTargetValue(); - // } - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - private static Notification getNotification(String title, String content, String activity, - Map<String, String> params) { - - Notification notification = new Notification(); - - /** - * - * 浠ヤ笅鍙傛暟蹇呭~椤� - * - */ - - notification.setTitle(title); - notification.setSubTitle(title); - notification.setContent(content); - - /** - * - * 浠ヤ笅鍙傛暟闈炲繀濉」锛� 濡傛灉闇�瑕佷娇鐢ㄥ彲浠ュ弬鑰僌PPO push鏈嶅姟绔痑pi鏂囨。杩涜璁剧疆 - * - */ - - // App寮�鍙戣�呰嚜瀹氫箟娑堟伅Id锛孫PPO鎺ㄩ�佸钩鍙版牴鎹ID鍋氬幓閲嶅鐞嗭紝瀵逛簬骞挎挱鎺ㄩ�佺浉鍚宎ppMessageId鍙細淇濆瓨涓�娆★紝瀵逛簬鍗曟帹鐩稿悓appMessageId鍙細鎺ㄩ�佷竴娆� - notification.setAppMessageId(UUID.randomUUID().toString()); - - // 搴旂敤鎺ユ敹娑堟伅鍒拌揪鍥炴墽鐨勫洖璋僓RL锛屽瓧鏁伴檺鍒�200浠ュ唴锛屼腑鑻辨枃鍧囦互涓�涓绠� - // notification.setCallBackUrl("http://www.test.com"); - // App寮�鍙戣�呰嚜瀹氫箟鍥炴墽鍙傛暟锛屽瓧鏁伴檺鍒�50浠ュ唴锛屼腑鑻辨枃鍧囦互涓�涓绠� - // notification.setCallBackParameter(""); - - // 鐐瑰嚮鍔ㄤ綔绫诲瀷0锛屽惎鍔ㄥ簲鐢紱1锛屾墦寮�搴旂敤鍐呴〉锛坅ctivity鐨刬ntent - // action锛夛紱2锛屾墦寮�缃戦〉锛�4锛屾墦寮�搴旂敤鍐呴〉锛坅ctivity锛夛紱銆愰潪蹇呭~锛岄粯璁ゅ�间负0銆�;5,Intent scheme URL - - notification.setClickActionType(4); - - // 搴旂敤鍐呴〉鍦板潃銆恈lick_action_type涓�1鎴�4鏃跺繀濉紝闀垮害500銆� - notification.setClickActionActivity(activity); - - // 缃戦〉鍦板潃銆恈lick_action_type涓�2蹇呭~锛岄暱搴�500銆� - // notification.setClickActionUrl("http://www.test.com"); - - // 鍔ㄤ綔鍙傛暟锛屾墦寮�搴旂敤鍐呴〉鎴栫綉椤垫椂浼犻�掔粰搴旂敤鎴栫綉椤点�怞SON鏍煎紡锛岄潪蹇呭~銆戯紝瀛楃鏁颁笉鑳借秴杩�4K锛岀ず渚嬶細{"key1":"value1","key2":"value2"} - - JSONObject paramsData = new JSONObject(); - if (params != null) - for (Iterator<String> its = params.keySet().iterator(); its.hasNext();) { - String key = its.next(); - paramsData.put(key, params.get(key)); - } - - notification.setActionParameters(paramsData.toJSONString()); - // 灞曠ず绫诲瀷 (0, 鈥滃嵆鏃垛��),(1, 鈥滃畾鏃垛��) - notification.setShowTimeType(0); - - // 瀹氭椂灞曠ず寮�濮嬫椂闂达紙鏍规嵁time_zone杞崲鎴愬綋鍦版椂闂达級锛屾椂闂寸殑姣鏁� - // notification.setShowStartTime(System.currentTimeMillis() + 1000 * 60 - // * 3); - - // 瀹氭椂灞曠ず缁撴潫鏃堕棿锛堟牴鎹畉ime_zone杞崲鎴愬綋鍦版椂闂达級锛屾椂闂寸殑姣鏁� - // notification.setShowEndTime(System.currentTimeMillis() + 1000 * 60 * - // 5); - - // 鏄惁杩涚绾挎秷鎭�,銆愰潪蹇呭~锛岄粯璁や负True銆� - - notification.setOffLine(true); - - // 绂荤嚎娑堟伅鐨勫瓨娲绘椂闂�(time_to_live) (鍗曚綅锛氱), 銆恛ff_line鍊间负true鏃讹紝蹇呭~锛屾渶闀�3澶┿�� - notification.setOffLineTtl(24 * 3600); - - // 鏃跺尯锛岄粯璁ゅ�硷細锛圙MT+08:00锛夊寳浜紝棣欐腐锛屾柊鍔犲潯 - notification.setTimeZone("GMT+08:00"); - // 0锛氫笉闄愯仈缃戞柟寮�, 1锛氫粎wifi鎺ㄩ�� - notification.setNetworkType(0); - return notification; - } - -} +package com.yeshi.fanli.util.push; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.yeshi.utils.annotation.MapUtil; + +import com.alibaba.fastjson.JSONObject; +import com.oppo.push.server.Notification; +import com.oppo.push.server.Result; +import com.oppo.push.server.Sender; +import com.oppo.push.server.Target; +import com.yeshi.fanli.entity.config.push.HWPushConfig; +import com.yeshi.fanli.exception.push.PushException; +import com.yeshi.fanli.service.inter.config.BusinessSystemService; +import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.taobao.TaoBaoUtil; + +@Component +public class OPPOPushUtil { + + private static OPPOPushUtil hWPushUtil; + + @Autowired + private BusinessSystemService businessSystemService; + + @PostConstruct + public void init() { + hWPushUtil = this; + hWPushUtil.businessSystemService = this.businessSystemService; + } + + private static String appkey = ""; + private static String masterSecret = ""; + + static { + Properties ps = org.yeshi.utils.PropertiesUtil + .getProperties(TaoBaoUtil.class.getClassLoader().getResourceAsStream("push_hw.properties")); + HWPushConfig config = (HWPushConfig) MapUtil.parseMap(HWPushConfig.class, ps); + appkey = config.getAppId(); + masterSecret = config.getAppSecret(); + } + + private static Map<String, String> getParams(String type, String activity, String url, String webUrl, String id) { + Map<String, String> data = new HashMap<>(); + if (type != null) + data.put("type", type); + if (activity != null) + data.put("activity", activity); + if (url != null) + data.put("url", url); + if (webUrl != null) + data.put("webUrl", webUrl); + if (id != null) + data.put("id", id + ""); + return data; + } + + /** + * 鎺ㄩ�佸晢鍝� + * + * @param registerIds + * -鏈�澶у��1000 + * @param title + * @param content + * @param goodsType + * @param goodsId + * @throws PushException + */ + public static void pushGoods(List<String> registerIds, String title, String content, int goodsType, String goodsId,String androidBaseActivity) + throws PushException { + if (registerIds != null && registerIds.size() > 100) + throw new PushException(1, "璁惧鏁颁笉鑳借秴杩�100涓�"); + + String activity =androidBaseActivity + + ".ui.recommend.GoodsBrowserActivity"; + Map<String, String> params = getParams("goodsdetail", activity, null, null, goodsId); + + try { + boolean success = push(registerIds, title, content, params); + if (!success) + throw new PushException(2, "鎺ㄩ�佸け璐�"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 缃戦〉鎺ㄩ�� + * + * @param registerIds + * 鏈�澶у��1000 + * @param title + * @param content + * @param url + * -缃戦〉閾炬帴 + * @throws PushException + */ + public static void pushUrl(List<String> registerIds, String title, String content, String url,String androidBaseActivity) + throws PushException { + if (registerIds != null && registerIds.size() > 100) + throw new PushException(1, "璁惧鏁颁笉鑳借秴杩�1000涓�"); + + String activity =androidBaseActivity + ".ui.invite.ShareBrowserActivity"; + Map<String, String> params = getParams("url", activity, null, url, null); + try { + boolean success = push(registerIds, title, content, params); + if (!success) + throw new PushException(2, "鎺ㄩ�佸け璐�"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 绔欏唴淇℃帹閫� + * + * @param registerIds + * 鏈�澶у��1000 + * @param title + * @param content + * -缃戦〉閾炬帴 + * @throws PushException + */ + public static void pushZNX(List<String> registerIds, String title, String content) throws PushException { + if (registerIds != null && registerIds.size() > 100) + throw new PushException(1, "璁惧鏁颁笉鑳借秴杩�100涓�"); + Map<String, String> params = getParams("ZNX", null, null, null, null); + if (params == null) + return; + + try { + boolean success = push(registerIds, title, content, params); + if (!success) + throw new PushException(2, "鎺ㄩ�佸け璐�"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void pushWEEX(List<String> registerIds, String title, String content, String weexUrl,String androidBaseActivity) + throws PushException { + String activity =androidBaseActivity + + ".ui.mine.weex.WeexApplicationActivity"; + Map<String, String> params = getParams("weex", activity, weexUrl, weexUrl, null); + if (params == null) + return; + + try { + boolean success = push(registerIds, title, content, params); + if (!success) + throw new PushException(2, "鎺ㄩ�佸け璐�"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void pushBaiChuanUrl(List<String> registerIds, String title, String content, String url) + throws PushException { + Map<String, String> params = getParams("baichuan", null, url, null, null); + if (params == null) + return; + + try { + boolean success = push(registerIds, title, content, params); + if (!success) + throw new PushException(2, "鎺ㄩ�佸け璐�"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void pushWelfareCenter(List<String> registerIds, String title, String content,String androidBaseActivity) throws PushException { + String activity =androidBaseActivity + ".ui.mine.WelfareCenterActivity"; + Map<String, String> params = getParams("welfare", activity, null, null, null); + if (params == null) + return; + + try { + boolean success = push(registerIds, title, content, params); + if (!success) + throw new PushException(2, "鎺ㄩ�佸け璐�"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void pushUserSignInNotification(List<String> registerIds, String title, String content,String androidBaseActivity) + throws PushException { + String activity =androidBaseActivity + ".ui.goldtask.GoldTaskActivity"; + Map<String, String> params = getParams("signin", activity, null, null, null); + if (params == null) + return; + + try { + boolean success = push(registerIds, title, content, params); + if (!success) + throw new PushException(2, "鎺ㄩ�佸け璐�"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * + * @param list + * 鏈�澶т负1000 + */ + public static boolean push(List<String> list, String title, String content, Map<String, String> dataParams) { + Map<String, String> params = null; + if (dataParams != null) { + params = new HashMap<>(); + JSONObject json = new JSONObject(); + for (Iterator<String> its = dataParams.keySet().iterator(); its.hasNext();) { + String key = its.next(); + json.put(key, dataParams.get(key)); + } + params.put("data", json.toJSONString()); + } + + try { + Sender sender = new Sender("f14S6P4sCrW4gs0WCO80w80cW", "E7976fe3d1758bf0c3480d8DcE4236e2"); + Notification notifyCation = getNotification(title, content, + "com.yeshi.ec.rebate.myapplication.ui.OPPOPushMessageActivity", params); + if (list.size() == 1) { + Result result = sender.unicastNotification(notifyCation, Target.build(list.get(0))); + result.getStatusCode(); // 鑾峰彇http璇锋眰鐘舵�佺爜 + result.getReturnCode(); // 鑾峰彇骞冲彴杩斿洖鐮� + System.out.println(result.getStatusCode() + "-" + result.getReturnCode()); + if (result.getReturnCode().getCode() == 0) + return true; + else + return false; + } else { + Map<Target, Notification> batch = new HashMap<Target, Notification>(); // batch鏈�澶т负1000 + for (String registerId : list) { + batch.put(Target.build(registerId), notifyCation); + } + Result result = sender.unicastBatchNotification(batch); // 鍙戦�佹壒閲忓崟鎺ㄦ秷鎭� + result.getStatusCode(); // 鑾峰彇http璇锋眰鐘舵�佺爜 + result.getReturnCode(); // 鑾峰彇骞冲彴杩斿洖鐮� + System.out.println(result.getStatusCode() + "-" + result.getReturnCode()); + if (result.getReturnCode().getCode() == 0) + return true; + else + return false; + } + + // List<Result.UnicastBatchResult> batchResult = + // result.getUnicastBatchResults(); // 鎵归噺鍗曟帹缁撴灉 + // for (Result.UnicastBatchResult record : batchResult) { + // record.getErrorCode(); + // record.getErrorMessage(); + // record.getMessageId(); + // record.getTargetValue(); + // } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + private static Notification getNotification(String title, String content, String activity, + Map<String, String> params) { + + Notification notification = new Notification(); + + /** + * + * 浠ヤ笅鍙傛暟蹇呭~椤� + * + */ + + notification.setTitle(title); + notification.setSubTitle(title); + notification.setContent(content); + + /** + * + * 浠ヤ笅鍙傛暟闈炲繀濉」锛� 濡傛灉闇�瑕佷娇鐢ㄥ彲浠ュ弬鑰僌PPO push鏈嶅姟绔痑pi鏂囨。杩涜璁剧疆 + * + */ + + // App寮�鍙戣�呰嚜瀹氫箟娑堟伅Id锛孫PPO鎺ㄩ�佸钩鍙版牴鎹ID鍋氬幓閲嶅鐞嗭紝瀵逛簬骞挎挱鎺ㄩ�佺浉鍚宎ppMessageId鍙細淇濆瓨涓�娆★紝瀵逛簬鍗曟帹鐩稿悓appMessageId鍙細鎺ㄩ�佷竴娆� + notification.setAppMessageId(UUID.randomUUID().toString()); + + // 搴旂敤鎺ユ敹娑堟伅鍒拌揪鍥炴墽鐨勫洖璋僓RL锛屽瓧鏁伴檺鍒�200浠ュ唴锛屼腑鑻辨枃鍧囦互涓�涓绠� + // notification.setCallBackUrl("http://www.test.com"); + // App寮�鍙戣�呰嚜瀹氫箟鍥炴墽鍙傛暟锛屽瓧鏁伴檺鍒�50浠ュ唴锛屼腑鑻辨枃鍧囦互涓�涓绠� + // notification.setCallBackParameter(""); + + // 鐐瑰嚮鍔ㄤ綔绫诲瀷0锛屽惎鍔ㄥ簲鐢紱1锛屾墦寮�搴旂敤鍐呴〉锛坅ctivity鐨刬ntent + // action锛夛紱2锛屾墦寮�缃戦〉锛�4锛屾墦寮�搴旂敤鍐呴〉锛坅ctivity锛夛紱銆愰潪蹇呭~锛岄粯璁ゅ�间负0銆�;5,Intent scheme URL + + notification.setClickActionType(4); + + // 搴旂敤鍐呴〉鍦板潃銆恈lick_action_type涓�1鎴�4鏃跺繀濉紝闀垮害500銆� + notification.setClickActionActivity(activity); + + // 缃戦〉鍦板潃銆恈lick_action_type涓�2蹇呭~锛岄暱搴�500銆� + // notification.setClickActionUrl("http://www.test.com"); + + // 鍔ㄤ綔鍙傛暟锛屾墦寮�搴旂敤鍐呴〉鎴栫綉椤垫椂浼犻�掔粰搴旂敤鎴栫綉椤点�怞SON鏍煎紡锛岄潪蹇呭~銆戯紝瀛楃鏁颁笉鑳借秴杩�4K锛岀ず渚嬶細{"key1":"value1","key2":"value2"} + + JSONObject paramsData = new JSONObject(); + if (params != null) + for (Iterator<String> its = params.keySet().iterator(); its.hasNext();) { + String key = its.next(); + paramsData.put(key, params.get(key)); + } + + notification.setActionParameters(paramsData.toJSONString()); + // 灞曠ず绫诲瀷 (0, 鈥滃嵆鏃垛��),(1, 鈥滃畾鏃垛��) + notification.setShowTimeType(0); + + // 瀹氭椂灞曠ず寮�濮嬫椂闂达紙鏍规嵁time_zone杞崲鎴愬綋鍦版椂闂达級锛屾椂闂寸殑姣鏁� + // notification.setShowStartTime(System.currentTimeMillis() + 1000 * 60 + // * 3); + + // 瀹氭椂灞曠ず缁撴潫鏃堕棿锛堟牴鎹畉ime_zone杞崲鎴愬綋鍦版椂闂达級锛屾椂闂寸殑姣鏁� + // notification.setShowEndTime(System.currentTimeMillis() + 1000 * 60 * + // 5); + + // 鏄惁杩涚绾挎秷鎭�,銆愰潪蹇呭~锛岄粯璁や负True銆� + + notification.setOffLine(true); + + // 绂荤嚎娑堟伅鐨勫瓨娲绘椂闂�(time_to_live) (鍗曚綅锛氱), 銆恛ff_line鍊间负true鏃讹紝蹇呭~锛屾渶闀�3澶┿�� + notification.setOffLineTtl(24 * 3600); + + // 鏃跺尯锛岄粯璁ゅ�硷細锛圙MT+08:00锛夊寳浜紝棣欐腐锛屾柊鍔犲潯 + notification.setTimeZone("GMT+08:00"); + // 0锛氫笉闄愯仈缃戞柟寮�, 1锛氫粎wifi鎺ㄩ�� + notification.setNetworkType(0); + return notification; + } + +} -- Gitblit v1.8.0